npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nestjs-fauna

v1.1.0

Published

The ultimate Fauna Db module for Nestjs

Downloads

10

Readme

NestJS Fauna

A NestJS package that provides seamless integration with FaunaDB, allowing you to interact with FaunaDB effortlessly within your NestJS applications.

Nest.Js Fauna

NestJS FaunaDB GitHub contributors GitHub language count GitHub issues GitHub GitHub repo size GitHub Super-Linter

Table of Contents

🚀 Installation

npm install nestjs-fauna

🤖 Getting Started

Before you start using this package, you need to have a FaunaDB account and a database set up. If you haven't already done this, head over to the FaunaDB site and follow their instructions to get started.

Once you have your FaunaDB credentials, you can configure the package in your NestJS application.

Configuration

In your NestJS application, create a .env file in the root directory and add your FaunaDB secret key:

FAUNADB_SECRET_KEY = your_faunadb_secret_key_here

Make sure to load the .env file using a package like dotenv in your application's main entry file (e.g., main.ts).

Module Registration

Register the FaunaDB module in your NestJS application. Import the FaunaModule and pass in the configuration options:

import { Module } from '@nestjs/common'
import { FaunaModule } from 'nestjs-fauna'

@Module({
  imports: [
    FaunaModule.forRoot({
      secret: process.env.FAUNADB_SECRET_KEY,
      // Other options if needed
    }),
  ],
})
export class AppModule {}

🏀 Usage

With the FaunaDB module configured, you can now inject the FaunaService into your services or controllers to interact with the FaunaDB client.

import { Injectable } from '@nestjs/common'
import { fql } from 'nestjs-fauna'

@Injectable()
export class MyService {
  constructor(private readonly faunaService: FaunaService) {}

  async getDocumentById(id: string): Promise<any> {
    // ensure you have the collection, or create a new one
    // then execute it
    const collectionQuery = fql`Collection.create({name: 'users'})`
    await this.faunaService.query(collectionQuery)

    // get the document from database
    const firstDocumentQuery = fql`users.all().first()`
    return this.faunaService.query(firstDocumentQuery)

    // result will be
    // something like this
    {
      id: "366172354849538082",
      coll: users,
      ts: Time("2023-05-30T17:33:40.220Z"),
      // your data
    }
  }

  // Add more methods to interact with FaunaDB as needed
}

In the example above, we use the FaunaService.query method to execute a query against the FaunaDB client. You can leverage FaunaDB's powerful query language to perform various operations on your collections and documents.

For more information on the available query functions and how to use them, refer to the FaunaDB documentation.

✅ Features

  • Seamless integration with NestJS applications.
  • Easy-to-use API for interacting with FaunaDB.
  • Utilizes FaunaDB's powerful query language for flexible database operations.
  • Configurable and supports multiple environments using environment variables.
  • Update using new version of FQL (version 10)

🩷 Contributing

We welcome contributions from the community to improve this package. If you find any issues or have suggestions for enhancements, please open an issue or submit a pull request.

To contribute please follow the instruction on Contributing

Please ensure your code follows the established coding standards and includes appropriate unit tests.

🪪 License

This project is licensed under the MIT License. Feel free to use and modify the code as you see fit.