{"id":15043894,"url":"https://github.com/scalio/nest-couchbase","last_synced_at":"2025-04-15T00:29:08.581Z","repository":{"id":35066274,"uuid":"198174575","full_name":"scalio/nest-couchbase","owner":"scalio","description":"Couchbase module for NestJS","archived":false,"fork":false,"pushed_at":"2023-01-04T07:21:22.000Z","size":1503,"stargazers_count":20,"open_issues_count":19,"forks_count":9,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-03-28T12:21:22.215Z","etag":null,"topics":["couchbase","database","nest","nestjs","nodejs","orm"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/scalio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-22T07:53:27.000Z","updated_at":"2023-07-27T19:39:58.000Z","dependencies_parsed_at":"2023-01-15T13:15:22.415Z","dependency_job_id":null,"html_url":"https://github.com/scalio/nest-couchbase","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scalio%2Fnest-couchbase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scalio%2Fnest-couchbase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scalio%2Fnest-couchbase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scalio%2Fnest-couchbase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scalio","download_url":"https://codeload.github.com/scalio/nest-couchbase/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650766,"owners_count":21139684,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["couchbase","database","nest","nestjs","nodejs","orm"],"created_at":"2024-09-24T20:49:47.559Z","updated_at":"2025-04-15T00:29:08.564Z","avatar_url":"https://github.com/scalio.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Couchbase for Nest](https://raw.githubusercontent.com/scalio/nest-couchbase/master/scalio-nc.svg?sanitize=true)\n\n\u003ch1 align=\"center\"\u003eNestJS Couchbase\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  A \u003ca href=\"https://www.couchbase.com/\"\u003eCouchbase\u003c/a\u003e module for \u003ca href=\"https://nestjs.com/\"\u003eNestJS\u003c/a\u003e\n\u003c/p\u003e\n\n\u0026nbsp;\n\n## Installation\n\n```bash\n$ npm i @scalio-oss/nest-couchbase couchbase\n```\n\n## Usage\n\n`@scalio-oss/nest-couchbase` uses [couchbase](https://www.npmjs.com/package/couchbase) as a data provider and the `Repository` pattern to handle all items (documents) related operations.\n\nFirst, let's create an `Entity`:\n\n```typescript\nimport { Entity } from '@scalio-oss/nest-couchbase';\n\n@Entity('cats')\nexport class Cat {\n  name: string;\n}\n```\n\nWhere `cats` is the Couchbase bucket name (optional).\n\nThen, we need to import `CouchbaseModule` in our root `AppModule`:\n\n```typescript\nimport { Module } from '@nestjs/common';\nimport { CouchbaseModule } from '@scalio-oss/nest-couchbase';\n\n@Module({\n  imports: [\n    CouchbaseModule.forRoot({\n      url: 'couchbase://127.0.0.1',\n      username: 'couchbase',\n      password: 'couchbase',\n      defaultBucket: {\n        name: 'test',\n        password: 'password',\n      },\n      buckets: [\n        {\n          name: 'another_bucket',\n          password: 'another_password',\n        },\n      ],\n    }),\n  ],\n})\nexport class AppModule {}\n```\n\nIn our `CatsModule` we need to initiate repository for our `Cat` entity:\n\n```typescript\nimport { Module } from '@nestjs/common';\nimport { CouchbaseModule } from '@scalio-oss/nest-couchbase';\nimport { CatsService } from './cats.service';\nimport { CatsController } from './cats.controller';\nimport { Cat } from './cat.entity';\n\n@Module({\n  imports: [CouchbaseModule.forFeature([Cat])],\n  providers: [CatsService],\n  controllers: [CatsController],\n})\nexport class CatsModule {}\n```\n\nAnd here is the usage of the repository in the service:\n\n```typescript\nimport { Injectable } from '@nestjs/common';\nimport { InjectRepository, Repository } from '@scalio-oss/nest-couchbase';\nimport { Cat } from './cat.entity';\n\n@Injectable()\nexport class CatsService {\n  constructor(\n    @InjectRepository(Cat)\n    private readonly catsRepository: Repository\u003cCat\u003e,\n  ) {}\n\n  findOne(id: string): Promise\u003cCat\u003e {\n    return this.catsRepository.get(id);\n  }\n}\n```\n\n## License\n\n[MIT](LICENSE)\n\n## Credits\n\nCreated by [@zMotivat0r](https://github.com/zMotivat0r) @ [Scalio](https://scal.io/)\n\n## About us\n\n\u003cp align=\"center\"\u003e\n    \u003cbr/\u003e\n    \u003ca href=\"https://scal.io/\"\u003e\n        \u003cimg src=\"https://raw.githubusercontent.com/scalio/bazel-status/master/assets/scalio-logo.svg?sanitize=true\" /\u003e\n    \u003c/a\u003e\n    \u003cbr/\u003e\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscalio%2Fnest-couchbase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscalio%2Fnest-couchbase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscalio%2Fnest-couchbase/lists"}