https://github.com/sliit-foss/enhanced_firebase_js_sdk
An enhanced version of cloud firestore dart package with support for filtering sorting, limiting, error handling, and success scenarios
https://github.com/sliit-foss/enhanced_firebase_js_sdk
Last synced: 3 months ago
JSON representation
An enhanced version of cloud firestore dart package with support for filtering sorting, limiting, error handling, and success scenarios
- Host: GitHub
- URL: https://github.com/sliit-foss/enhanced_firebase_js_sdk
- Owner: sliit-foss
- License: mit
- Created: 2022-03-16T16:07:31.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-05-17T18:14:28.000Z (about 3 years ago)
- Last Synced: 2025-01-25T11:42:26.636Z (5 months ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/enhanced_firebase_js_sdk
- Size: 13.7 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# enhanced_firebase_js_sdk
An enhanced version of the firebase js sdk with firestore and realtime database support for filtering sorting, limiting, error handling, and success scenarios## Installation
```js
# using npm
npm install enhanced_firebase_js_sdk# using yarn
yarn add enhanced_firebase_js_sdk
```## Usage
```js
# using require
const { firestoreService } = require("enhanced_firebase_js_sdk");# using import
import { firestoreService } from "enhanced_firebase_js_sdk";
```## Example - Firestore
```js
// read
const users = await firestoreService.read({ collectionName: 'users' })// write
const result = await firestoreService.write({ collectionName: 'users', payload: { name : 'Ciri' , age: 19 } })// update
const result = await firestoreService.update({
collectionName: 'users',
payload: { age: 20 },
filters: [
{
key: 'name',
operator: '==',
value: 'Ciri',
},
],
})// delete
const result = await firestoreService.remove({ collectionName: 'users' })```
## Additional Options
- The read, update and delete functions can take in the additional parameter **filters** which is an array of objects indicating the filtering criteria of the results. The supported operators are the same as the ones provided in the **firebase docs** (https://cloud.google.com/firestore/docs/query-data/queries#query_operators)
- The read function can take in the additional parameters **sorts** and **recordLimit** where sorts is an array of objects indicating the sorting criteria of the results and recordLimit is an integer which limits the number of records returned from the query.
- The write function can take in the additional parameters **documentId** which will allow you to create documents with a provided documentId as opposed to its auto generated behavior and **merge** which will allow you to merge the newly provided payload with the existing data at the provided path if it exists.
- All functions can take in the additional parameters **onSuccess** and **onError** which are callback functions which will get executed on success and failure scenarios respectively. **The onSuccess callback is passed the result of the operation as a parameter by default** whereas **the onError function is passed the error or details of the error which occurred**.
----
Based on the original cloud firebase package by Google (https://www.npmjs.com/package/firebase)