Skip to content

Commit

Permalink
Merge pull request #11 from nyomansunima/fauna-js-update
Browse files Browse the repository at this point in the history
Fauna js update
  • Loading branch information
nyomansunima authored Aug 24, 2023
2 parents 1e89f9e + fe16749 commit dd4f4e6
Show file tree
Hide file tree
Showing 9 changed files with 2,095 additions and 454 deletions.
25 changes: 25 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: __dirname,
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
}
58 changes: 0 additions & 58 deletions .github/workflows/linter.yml

This file was deleted.

34 changes: 25 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 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](https://github.com/nyomansunima/nestjs-fauna/assets/54091887/fddd548e-d5c3-46ac-8ce0-7ef49a1664e0)

<!-- Shields -->
Expand All @@ -11,10 +15,6 @@
![GitHub repo size](https://img.shields.io/github/repo-size/nyomansunima/nestjs-fauna)
[![GitHub Super-Linter](https://github.com/nyomansunima/nestjs-fauna/actions/workflows/linter.yml/badge.svg)](https://github.com/marketplace/actions/super-linter)

# NestJS Fauna

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

## Table of Contents

- [Installation](#installation)
Expand All @@ -32,7 +32,7 @@ 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 website](https://fauna.com/) and follow their instructions to get 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](https://fauna.com/) and follow their instructions to get started.

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

Expand Down Expand Up @@ -71,14 +71,30 @@ With the FaunaDB module configured, you can now inject the `FaunaService` into y

```typescript
import { Injectable } from '@nestjs/common'
import { FaunaService, Collection, Ref, Get } from 'nestjs-fauna'
import { fql } from 'nestjs-fauna'

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

async getDocumentById(id: string): Promise<any> {
return this.faunaService.query(Get(Ref(Collection('my_collection'), id)))
// 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
Expand All @@ -95,8 +111,8 @@ For more information on the available query functions and how to use them, refer
- 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.

<br/>
- Update using new version of FQL (version 10)
<br/>

## 🩷 Contributing

Expand Down
Loading

0 comments on commit dd4f4e6

Please sign in to comment.