Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

get number of new document firebasse

export const documentWriteListener = functions.firestore
  .document('collection/{documentUid}')
  .onWrite((change, context) => {

    if (!change.before.exists) {
      // New document Created : add one to count
      db.doc(docRef).update({ numberOfDocs: FieldValue.increment(1) });
    } else if (change.before.exists && change.after.exists) {
      // Updating existing document : Do nothing
    } else if (!change.after.exists) {
      // Deleting document : subtract one from count
      db.doc(docRef).update({ numberOfDocs: FieldValue.increment(-1) });
    }

    return;
  });
Comment

PREVIOUS NEXT
Code Example
Javascript :: use strict print this 
Javascript :: how to get event from iframe 
Javascript :: add seconds to date 
Javascript :: how to convert python code to javascript 
Javascript :: decode jwt token in angular 
Javascript :: copy array 
Javascript :: anonymous function js 
Javascript :: convert milliseconds to dd/mm/yyyy javascript 
Javascript :: javascript get object methods 
Javascript :: new react 
Javascript :: hello world js 
Javascript :: javasript array 
Javascript :: javascript last element 
Javascript :: javascript link to page 
Javascript :: remove backslash from json 
Javascript :: instance in javascript 
Javascript :: how to add suffix to a string in javascript 
Javascript :: EFSavechanges 
Javascript :: regex concatenazione 
Javascript :: JavaScript Methods and this Keyword 
Javascript :: return number less than in 250 
Javascript :: javascript Octal syntax is not allowed 
Javascript :: nuxt login with google strategie 
Javascript :: code grepper temp email number and password 
Javascript :: How to get prime numbers using for loop in Js 
Javascript :: connect phantom wallet react typescript 
Javascript :: phaser animation on stop event 
Javascript :: core.mjs:4057 JIT compilation failed for NgModule class AppModule 
Javascript :: nodejs stream pipeline 
Javascript :: enum jpa jsf jakarta9 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =