# easy-firestore

> This package will help you in getting and adding data with firebase

Latest version **1.1.1** (published 2022-08-21) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2022-08-21 |
| First published | 2022-08-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Moussa Alkaly BADJI |
| Maintainers | alkaly |
| Keywords | [firebase, firestore, data, documents, noSql] |

## Links

- npm: https://www.npmjs.com/package/easy-firestore
- Repository: https://github.com/Alkaly02/easy-firestore
- Homepage: https://github.com/Alkaly02/easy-firestore#readme
- Issues: https://github.com/Alkaly02/easy-firestore/issues
- npm.io page: https://npm.io/package/easy-firestore

## Alternatives

- [@libsql/sqlite3](https://npm.io/package/@libsql/sqlite3.md) — 39.8K weekly downloads
- [@fortemi/core](https://npm.io/package/@fortemi/core.md) — 461 weekly downloads
- [cdb-converter](https://npm.io/package/cdb-converter.md) — 341 weekly downloads
- [@uplo/adapter-prisma](https://npm.io/package/@uplo/adapter-prisma.md) — 75 weekly downloads
- [typeorm-aios](https://npm.io/package/typeorm-aios.md) — 30 weekly downloads

## Recent versions

- 1.1.1 (latest) — 2022-08-21
- 1.1.0 — 2022-08-21
- 1.0.5 — 2022-08-20
- 1.0.4 — 2022-08-20
- 1.0.3 — 2022-08-20
- 1.0.2 — 2022-08-20
- 1.0.1 — 2022-08-20
- 1.0.0 — 2022-08-20

## README

# easy-firestore
This package will help you in getting data and managing images with firebase. 

## Installation
```
npm i easy-firestore

or 

yarn add easy-firestore
```

## API Reference

### Get all documents in a collection

```
import {useDocs} from "easy-firestore/hooks"

const {data, numberOfData, dataLoading} = useDocs(db, collectionName)
```

| Parameter | Type     | Description                |
| :-------- | :------- | :------------------------- |
| `db`      | | **Required**. Your firestore database |
| `collectionName`| `string`| **Required**. Your collection name|
| `data`| `array` | All data in the collection|
| `numberOfData`| `number`| Number of items in your collection|
| `dataLoading`| `boolean`| Tells you if the process of getting data is done or not|


#### Example

```
const {data: products, numberOfData: numberOfProducts, dataLoading: productsLoading} = useDocs(db, "products")

products.forEach(product => (
  console.log(product.id)
))
```
### Get all documents that matched to a condition in a collection

```
import {useWhereDocs} from "easy-firestore/hooks"

const {data, numberOfData, dataLoading} = useWhereDocs(db, collectionName, whereToLookInTheDocument, whereToLookValue)
```
| Parameter | Type     | Description                |
| :-------- | :------- | :------------------------- |
| `db`      | | **Required**. Your firestore database |
| `collectionName`| `string`| **Required**. Your collection name|
| `whereToLookInTheDocument`| `string`| **Required**. The field of the document that has to match to the condition|
| `whereToLookValue`| `number or string`| **Required**. The value we will use to check if it matched with the document field|
| `data`| `array` | All data in the collection|
| `numberOfData`| `number`| Number of items in your collection|
| `dataLoading`| `boolean`| Tells you if the process of getting data is done or not|


```
const {data: users, numberOfData: numberOfUsers, dataLoading: usersLoading} = useWhereDocs(db, "users", "city", "senegal")

users.forEach(user => (
  console.log(user.firstname)
))

```


### Get the url image

```
import {useImgUrl} from "easy-firestore/hooks"

const {imgUrl, setImgUrl, percentage} = useImgUrl(storage, file)
```

| Parameter | Type     | Description                |
| :-------- | :------- | :------------------------- |
| `storage`      | | **Required**. Your firestore storage |
| `file`| `object`| **Required**. The selected file from your pictures|
| `imgUrl`| `string` | The url of your selected image that you can store on firestore then use it any where|
| `percentage`| `number`| You can use this number to create a progressive bar|

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