# enhanced_firebase_js_sdk

> An enhanced version of cloud firestore npm package with support for filtering sorting, limiting, error handling and success scenarios

Latest version **1.0.1** (published 2022-05-17) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install enhanced_firebase_js_sdk
pnpm add enhanced_firebase_js_sdk
yarn add enhanced_firebase_js_sdk
bun add enhanced_firebase_js_sdk
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2022-05-17 |
| First published | 2022-05-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 14.2 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | SLIIT-FOSS |
| Maintainers | sliit.foss |
| Keywords | firebase, firestore, enchanced-firestore |

## Links

- npm: https://www.npmjs.com/package/enhanced_firebase_js_sdk
- Repository: https://github.com/sliit-foss/enchanced_firebase_js_sdk
- Homepage: https://github.com/sliit-foss/enchanced_firebase_js_sdk#readme
- Issues: https://github.com/sliit-foss/enchanced_firebase_js_sdk/issues
- npm.io page: https://npm.io/package/enhanced_firebase_js_sdk

## Dependencies (2)

- [firebase](https://npm.io/package/firebase.md) ^9.4.1
- [dotenv-cli](https://npm.io/package/dotenv-cli.md) ^5.1.0

## Recent versions

- 1.0.1 (latest) — 2022-05-17
- 1.0.0 — 2022-05-17

## 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<br/>

```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**.<br/><br/>

----

<br/>Based on the original cloud firebase package by Google (https://www.npmjs.com/package/firebase)

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