# rz-firestore

> A facade service to simply communicate with Google Cloud Firestore DB

Latest version **1.0.3** (published 2021-07-17) · 0 weekly downloads

## Install

```sh
npm install rz-firestore
pnpm add rz-firestore
yarn add rz-firestore
bun add rz-firestore
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2021-07-17 |
| First published | 2021-04-12 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 110 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | roizofiof |

## Links

- npm: https://www.npmjs.com/package/rz-firestore
- npm.io page: https://npm.io/package/rz-firestore

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^2.0.0

## Recent versions

- 1.0.3 (latest) — 2021-07-17
- 1.0.2 — 2021-04-15
- 1.0.1 — 2021-04-12
- 1.0.0 — 2021-04-12

## README

# RZ Firestore

A facade service to simply communicate with Google Cloud Firestore DB


## Before you use

1. npm install firebase

2. npm install @angular/fire

3. In your module's imports array add: AngularFireModule.initializeApp(environment.firebaseConfig)


## Methods

### readStream&lt;T&gt;(collection: string, query?: RZFirestoreQuery, config?: RZFirestoreConfig): Observable&lt;T[]&gt;

Gets documents array on every DB change


### read&lt;T&gt;(collection: string, query?: RZFirestoreQuery, config?: RZFirestoreConfig): Promise&lt;T[]&gt;

Gets documents array


### readByDocumentId&lt;T&gt;(collection: string, id: string, config?: RZFirestoreConfig): Promise&lt;T&gt;

Gets document by ID


### create(collection: string, document: object): Promise&lt;string&gt;

Creates a new document and returns the its ID


### update(collection: string, id: string, document: object): Promise&lt;void&gt;

Creates a new document or replaces entire existing document


### patch(collection: string, id: string, propertiesToChange: object): Promise&lt;void&gt;

Creates or changes properties of existing document (not deletes)


### delete(collection: string, id: string): Promise&lt;void&gt;

Deletes an existing document


### toReference(collection: string, id: string): DocumentReference

Gets a document reference


### RZFirestoreQuery Object

RZFirestoreQuery {
&nbsp;&nbsp; where?: RZFirestoreFilter[]; <-- Logical AND relation<br />
&nbsp;&nbsp; orderBy?: RZFirestoreSort[]; <-- Logical AND relation<br />
&nbsp;&nbsp; limit?: number;<br />
}

RZFirestoreFilter {<br />
&nbsp;&nbsp; field: string;<br />
&nbsp;&nbsp; operator: RZFirestoreFilterOperator;<br />
&nbsp;&nbsp; value: unknown;<br />
}

RZFirestoreSort {<br />
&nbsp;&nbsp; field: string;<br />
&nbsp;&nbsp; direction?: RZFirestoreSortDirection;<br />
}

enum RZFirestoreFilterOperator {<br />
&nbsp;&nbsp; Equal = '==',<br />
&nbsp;&nbsp; NotEqual = '!=',<br />
&nbsp;&nbsp; LessThan = '<',<br />
&nbsp;&nbsp; LessThanEqual = '<=',<br />
&nbsp;&nbsp; GreaterThan = '>',<br />
&nbsp;&nbsp; GreaterThanEqual = '>=',<br />
&nbsp;&nbsp; In = 'in',<br />
&nbsp;&nbsp; NotIn = 'not-in',<br />
&nbsp;&nbsp; ArrayContains = 'array-contains',<br />
&nbsp;&nbsp; ArrayContainsAny = 'array-contains-any'<br />
}

enum RZFirestoreSortDirection {<br />
&nbsp;&nbsp; Asc = 'asc',<br />
&nbsp;&nbsp; Desc = 'desc'<br />
}


### RZFirestoreConfig Object

includeDocumentId: boolean (default true)<br />
(id fields are included automatically in documents, change this parameter to false to prevent it)

refConversionDepth: number (default 10)<br />
(references are converted automatically to documents, this parameter declares how deep to go with the conversion. 0 for no conversion at all)

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