Ad
How To Create Document Id For Firestore Documents Using AdminSdk In Firebase Cloud Functions?
How to create a document push id for firestore document using Firebase Admin SDK in Firebase cloud function.
I know how to do it in Angular using AngularFire2
const bookingId = this.afs.createId();
I need to do this thing in my cloud function.
Ad
Answer
Just call doc() with no arguments on a CollectionReference where you would like the document to live. You can then call set() on that returned DocumentReference to create the document.
If you don't even need to create the document and just want the random ID, use the id property on the DocumentReference.
(Realtime Database called these things "push IDs" because you used the push()
method, but they're just called auto generated IDs in Firestore).
Ad
source: stackoverflow.com
Related Questions
- → Maximum call stack exceeded when instantiating class inside of a module
- → Browserify api: how to pass advanced option to script
- → Node.js Passing object from server.js to external modules?
- → gulp-rename makes copies, but does not replace
- → requiring RX.js in node.js
- → Remove an ObjectId from an array of objectId
- → Can not connect to Redis
- → React: How to publish page on server using React-starter-kit
- → Express - better pattern for passing data between middleware functions
- → Can't get plotly + node.js to stream data coming through POST requests
- → IsGenerator implementation
- → Async/Await not waiting
- → (Socket.io on nodejs) Updating div with mysql data stops without showing error
Ad