From 89afaeb81441fb558c10eb62b2c585f8b645e3e9 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 16 Apr 2019 10:19:04 -0700 Subject: [PATCH] docs: Add example for Precondition (#601) --- dev/src/index.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dev/src/index.ts b/dev/src/index.ts index c869df928..ff21854f3 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -133,6 +133,16 @@ const GRPC_UNAVAILABLE = 14; * can be restricted to only apply to documents that match the specified * conditions. * + * @example + * const documentRef = firestore.doc('coll/doc'); + * + * documentRef.get().then(snapshot => { + * const updateTime = snapshot.updateTime; + * + * console.log(`Deleting document at update time: ${updateTime.toDate()}`); + * return documentRef.delete({ lastUpdateTime: updateTime }); + * }); + * * @property {string} lastUpdateTime The update time to enforce (specified as * an ISO 8601 string). * @typedef {Object} Precondition