1.1.1 • Published 2 years ago

easy-firestore v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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)
ParameterTypeDescription
dbRequired. Your firestore database
collectionNamestringRequired. Your collection name
dataarrayAll data in the collection
numberOfDatanumberNumber of items in your collection
dataLoadingbooleanTells 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)
ParameterTypeDescription
dbRequired. Your firestore database
collectionNamestringRequired. Your collection name
whereToLookInTheDocumentstringRequired. The field of the document that has to match to the condition
whereToLookValuenumber or stringRequired. The value we will use to check if it matched with the document field
dataarrayAll data in the collection
numberOfDatanumberNumber of items in your collection
dataLoadingbooleanTells 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)
ParameterTypeDescription
storageRequired. Your firestore storage
fileobjectRequired. The selected file from your pictures
imgUrlstringThe url of your selected image that you can store on firestore then use it any where
percentagenumberYou can use this number to create a progressive bar
1.1.1

2 years ago

1.1.0

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago