# nestjs-faunadb

> NestJS FaunaDB module

Latest version **1.0.2** (published 2020-03-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install nestjs-faunadb
pnpm add nestjs-faunadb
yarn add nestjs-faunadb
bun add nestjs-faunadb
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2020-03-11 |
| First published | 2020-03-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 13.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Author | Lewis Yuburi |
| Maintainers | lewyuburi |
| Keywords | nestjs, faunadb |

## Links

- npm: https://www.npmjs.com/package/nestjs-faunadb
- Repository: https://github.com/lewyuburi/nestjs-faunadb
- Homepage: https://github.com/lewyuburi/nestjs-faunadb#readme
- Issues: https://github.com/lewyuburi/nestjs-faunadb
- npm.io page: https://npm.io/package/nestjs-faunadb

## Dependencies (3)

- [rxjs](https://npm.io/package/rxjs.md) ^6.5.4
- [faunadb](https://npm.io/package/faunadb.md) ^2.13.0
- [reflect-metadata](https://npm.io/package/reflect-metadata.md) ^0.1.13

## Recent versions

- 1.0.2 (latest) — 2020-03-11
- 1.0.1 — 2020-03-11
- 1.0.0 — 2020-03-11

## README

<p align="center">
  <h3 align="center">
    nestjs-faunadb
  </h3>

  <p align="center">
    A FaunaDB module for Nestjs
  </p>
</p>

## Table Of Contents

- [Installation](#installation)
- [Getting Started](#getting-started)
- [Contributing](#contributing)
- [License](#license)
- [Acknowledgements](#acknowledgements)

## Installation

```bash
npm install --save nestjs-faunadb
```

## Getting Started

The simplest way to use `nestjs-faunadb` is to use `FaunadbModule.forRoot`

```typescript
import { Module } from '@nestjs/common';
import { FaunadbModule, FaunadbModuleOptions } from 'nestjs-faunadb';
import { AppController } from './app.controller';
import { AppService } from './app.service';

const fdbConfig: FaunadbModuleOptions = {
  secret: 'your-faunadb-secret-key'
}

@Module({
  imports: [
    FaunadbModule.forRoot(fdbConfig)
  ],
  controllers: [AppController],
  providers: [AppService],
})

export class AppModule {}
```

You can then inject the FaunaDB client into any of your injectables

```typescript
import { Injectable } from '@nestjs/common';
import { FaunadbService, query as q, Client, values } from 'nestjs-faunadb';

@Injectable()
export class AppService {

  client: Client;

  constructor(private readonly faunadbService: FaunadbService) {
    this.client = faunadbService.getClient()
  }

  async getHello(): Promise<object> {
    const testCollection = q.Collection('test')
    const data = { testField: 'testValue' }

    const query = q.Create(testCollection, { data })

    const result: values.Ref = await this.client.query(query)

    return result;
  }
}
```
That's it!

## Contributing

I would greatly appreciate any contributions to make this project better. Please
make sure to follow the below guidelines before getting your hands dirty.

1. Fork the repository
2. Create your branch (`git checkout -b my-branch`)
3. Commit any changes to your branch
4. Push your changes to your remote branch
5. Open a pull request

## License

Distributed under the ISC License. See `LICENSE` for more information.

## Acknowledgements

- [nestjs](https://nestjs.com)
- [faunadb](https://docs.fauna.com/fauna/current/drivers/javascript)

---
_Source: https://npm.io/package/nestjs-faunadb · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
