faunadb-nestjs
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

📂 faunadb-nestjs

Reusable NestJs package for Fauna dB connection.

Install

npm install --save faunadb-nestjs
# or
yarn add faunadb-nestjs

Usage

Sample implementation

import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { FaunaModule } from 'faunadb-nestjs';

@Module({
  imports: [
    FaunaModule.forRoot({
      secret: 'xxxxxxxxxxxxxxxxxx',
      db_name: 'xxxxxxxx',
    }),
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}
import { Injectable } from '@nestjs/common';
import { FaunaService } from 'faunadb-nestjs';

@Injectable()
export class AppService {
  constructor(private faunaService: FaunaService) {}
  async getCustomers(): Promise<any> {
    const customers = await this.faunaService.getDocuments('Customer');
    return customers;
  }
}
import { Injectable } from '@nestjs/common';
import { FaunaService, Client, query as q } from 'faunadb-nestjs';

@Injectable()
export class AppService {
  private client: Client;
  constructor(private faunaService: FaunaService) {
    this.client = this.faunaService.getClient();
  }
  async getCustomers(): Promise<any> {
    const customers = await this.client.query(
      q.Map(
        q.Paginate(q.Documents(q.Collection('Customer'))),
        q.Lambda('x', q.Get(q.Var('x'))),
      ),
    );
    return customers;
  }
}

Author

Zahir

License

MIT

Package Sidebar

Install

npm i faunadb-nestjs

Weekly Downloads

3

Version

1.0.5

License

MIT

Unpacked Size

19.8 kB

Total Files

19

Last publish

Collaborators

  • mzislam25