Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

apply limit to fetch number of documents firebase firestore

// imports
import React, { useEffect, useState } from "react";
import { db } from "../firebase";
import {
    onSnapshot,
    collection,
    query,
    where,
    limit,
} from "firebase/firestore";

// code 

const [data, setData] = useState([]);
    useEffect(() =>
        onSnapshot(
            query(
                collection(db, "products"),
                where("trending", "==", true),
                limit(8)
            ),
            (snapshot) => {
                setData(
                    snapshot.docs.map((doc) => {
                        return { ...doc.data() };
                    })
                );
            }
        )
    );
Comment

PREVIOUS NEXT
Code Example
Typescript :: typescript dictionary usestate 
Typescript :: typescript enum get key by value 
Typescript :: typescript convert to javascript 
Typescript :: Vue In Typescript 
Typescript :: writhing requests to text file 
Typescript :: routerextensions nativescript 7 import 
Typescript :: node rts stream 
Typescript :: based on previous make validation for required in reactive forms 
Typescript :: typescript question mark 
Typescript :: nest custom class validator 
Typescript :: Update multiple documents with different field value by id set. Mongoose 
Typescript :: distance between two lat long points google maps api 
Typescript :: t sql if exists multiple conditions 
Typescript :: democrats are pussies 
Typescript :: get coin prices node-binance 
Cpp :: cpp starting code 
Cpp :: #include<bits/stdc++.h 
Cpp :: How to make two dimensional string in c++ 
Cpp :: c++ reverse vector 
Cpp :: c++ usleep() 
Cpp :: Runtime Error: Runtime ErrorBad memory access (SIGBUS) 
Cpp :: how to shut down windows in c++ 
Cpp :: infinity c++ 
Cpp :: search update delete files in c++ 
Cpp :: sfml mouse click 
Cpp :: how to make a sqlite3 object in cpp 
Cpp :: c++ default array value not null 
Cpp :: C compile SDL program using mingw 
Cpp :: length of 2d array c++ 
Cpp :: how to declrae an array of size 1 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =