Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

firestore get first document in collection and delete it

// you need a reference field like timestamp
// this will work in a cloud function
return admin.firestore().collection("yourCollection")
.orderBy("yourTimestamp", "desc")
.limit(1)
.get()
.then(querySnapshot => {
    if (!querySnapshot.empty) {
        //We know there is one doc in the querySnapshot
        const queryDocumentSnapshot = querySnapshot.docs[0];
        return queryDocumentSnapshot.ref.delete();
    } else {
        console.log("No document corresponding to the query!");
        return null;
    }
});
Comment

firestore get first document in collection and delete it

return admin.firestore().collection("yourCollection")
.orderBy("yourTimestamp", "desc")
.limit(1)
.get()
.then(querySnapshot => {
    if (!querySnapshot.empty) {
        //We know there is one doc in the querySnapshot
        const queryDocumentSnapshot = querySnapshot.docs[0];
        return queryDocumentSnapshot.ref.delete();
    } else {
        console.log("No document corresponding to the query!");
        return null;
    }
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: Vue Apexchart LineChart 
Javascript :: table antd dosen t update 
Javascript :: next/image working without setting domain 
Javascript :: Angular generate by skipping test files 
Javascript :: submit file js 
Javascript :: Implementing basic set operations set object javascript 
Javascript :: .catch() in promise will aslo return a promise 
Javascript :: check if element is displayed jsavascript 
Javascript :: java script discord timer 
Javascript :: javascript nested destructuring 
Javascript :: Preselecting options select2 angularjs 
Javascript :: utility javascript function list 
Javascript :: check for changes in other store NUXT JS 
Javascript :: public url react for serving django static in production 
Javascript :: js destructuring arguments 
Javascript :: get last day of month js 
Javascript :: Function As Parameter In Self Invoking Function 
Javascript :: jquery validate min and max value 
Javascript :: hacker news api react 
Javascript :: react extends component with style 
Javascript :: React Native Component with Random Hexa 
Javascript :: s3 getobject not getting large json object 
Javascript :: ticket draw 
Javascript :: numberformat chakra 
Javascript :: List content on thee currentwdr 
Javascript :: lwc reduceErrors showtoast 
Javascript :: js create an object from another object with some keys removed 
Javascript :: index wise print elemnet in javascript 
Javascript :: $Javascript $.get( 
Javascript :: clear timers nodejs 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =