GithubHelp home page GithubHelp logo

scalio / nest-couchbase Goto Github PK

View Code? Open in Web Editor NEW
20.0 22.0 9.0 1.47 MB

Couchbase module for NestJS

License: MIT License

JavaScript 1.82% TypeScript 98.18%
nestjs nest nodejs couchbase orm database

nest-couchbase's Introduction

Couchbase for Nest

NestJS Couchbase

A Couchbase module for NestJS

ย 

Installation

$ npm i @scalio-oss/nest-couchbase couchbase

Usage

@scalio-oss/nest-couchbase uses couchbase as a data provider and the Repository pattern to handle all items (documents) related operations.

First, let's create an Entity:

import { Entity } from '@scalio-oss/nest-couchbase';

@Entity('cats')
export class Cat {
  name: string;
}

Where cats is the Couchbase bucket name (optional).

Then, we need to import CouchbaseModule in our root AppModule:

import { Module } from '@nestjs/common';
import { CouchbaseModule } from '@scalio-oss/nest-couchbase';

@Module({
  imports: [
    CouchbaseModule.forRoot({
      url: 'couchbase://127.0.0.1',
      username: 'couchbase',
      password: 'couchbase',
      defaultBucket: {
        name: 'test',
        password: 'password',
      },
      buckets: [
        {
          name: 'another_bucket',
          password: 'another_password',
        },
      ],
    }),
  ],
})
export class AppModule {}

In our CatsModule we need to initiate repository for our Cat entity:

import { Module } from '@nestjs/common';
import { CouchbaseModule } from '@scalio-oss/nest-couchbase';
import { CatsService } from './cats.service';
import { CatsController } from './cats.controller';
import { Cat } from './cat.entity';

@Module({
  imports: [CouchbaseModule.forFeature([Cat])],
  providers: [CatsService],
  controllers: [CatsController],
})
export class CatsModule {}

And here is the usage of the repository in the service:

import { Injectable } from '@nestjs/common';
import { InjectRepository, Repository } from '@scalio-oss/nest-couchbase';
import { Cat } from './cat.entity';

@Injectable()
export class CatsService {
  constructor(
    @InjectRepository(Cat)
    private readonly catsRepository: Repository<Cat>,
  ) {}

  findOne(id: string): Promise<Cat> {
    return this.catsRepository.get(id);
  }
}

License

MIT

Credits

Created by @zMotivat0r @ Scalio

About us



nest-couchbase's People

Contributors

amkartashov avatar bmgdev avatar michaelyali avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nest-couchbase's Issues

Further progress

Thanks for creating this project! I've been looking for nice typescript support for couchbase. I have your library up and running, but don't see many methods. Are you planning on adding some insert methods?

Dead repository?

I am interested in using Couchbase with NestJs and I find this library but I see that it was not updated again, is the project abandoned?

Out of date

Looks like this project is out of date with the Couchbase dependency.

this.cluster.authenticate(this.config.username, this.config.password);

TypeError: this.cluster.manager is not a function

Cannot find module

Hello,
After installing @scalio-oss/nest-couchbase with the command line $ npm i @scalio-oss/nest-couchbase couchbase, I got this issue by running $ npm run start :

[19:14:07] Starting compilation in watch mode...

[19:14:09] Found 0 errors. Watching for file changes.

Debugger listening on ws://127.0.0.1:9229/039206f6-a852-418c-8431-5ca955179952
For help, see: https://nodejs.org/en/docs/inspector
Error: Cannot find module 'couchbase/lib/bucket'
Require stack:

  • /home/gautier/Documents/GLOTELHO PROJECTS/TESTS-PROJECTS/new.nestjs.structure.test-project/node_modules/@scalio-oss/nest-couchbase/couchbase/couchbase.repository.mixin.js
  • /home/gautier/Documents/GLOTELHO PROJECTS/TESTS-PROJECTS/new.nestjs.structure.test-project/node_modules/@scalio-oss/nest-couchbase/couchbase/couchbase.repository.factory.js
  • /home/gautier/Documents/GLOTELHO PROJECTS/TESTS-PROJECTS/new.nestjs.structure.test-project/node_modules/@scalio-oss/nest-couchbase/couchbase/index.js
  • /home/gautier/Documents/GLOTELHO PROJECTS/TESTS-PROJECTS/new.nestjs.structure.test-project/node_modules/@scalio-oss/nest-couchbase/module/couchbase-core.module.js
  • /home/gautier/Documents/GLOTELHO PROJECTS/TESTS-PROJECTS/new.nestjs.structure.test-project/node_modules/@scalio-oss/nest-couchbase/module/couchbase.module.js
  • /home/gautier/Documents/GLOTELHO PROJECTS/TESTS-PROJECTS/new.nestjs.structure.test-project/node_modules/@scalio-oss/nest-couchbase/module/index.js
  • /home/gautier/Documents/GLOTELHO PROJECTS/TESTS-PROJECTS/new.nestjs.structure.test-project/node_modules/@scalio-oss/nest-couchbase/index.js
  • /home/gautier/Documents/GLOTELHO PROJECTS/TESTS-PROJECTS/new.nestjs.structure.test-project/dist/app.module.js
  • /home/gautier/Documents/GLOTELHO PROJECTS/TESTS-PROJECTS/new.nestjs.structure.test-project/dist/main.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object. (/home/gautier/Documents/GLOTELHO PROJECTS/TESTS-PROJECTS/new.nestjs.structure.test-project/node_modules/@scalio-oss/src/couchbase/couchbase.repository.mixin.ts:2:1)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)

Lack of example and documentation

There is not enough example and documentation in project. So it is hard for people to use it. Please provide some example, for example a CRUD example, at least.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.