I'd like to save the id of my document as a property as well, not only as a reference on the collection. At the moment I save it like this:
const newSet: AngularFirestoreDocument<SetModel> = this.AngularFirestore.doc('users/' + this.navParams.data.userId);
// adding user to our ddbb
newSet.collection('sets').add(this.set)
.then(function (docRef) {
// ok
})
.catch(function (error) {
// error
});
Would be that possible? Or do I need to save it, get the id and update it again?
PS this is my ddbb structure:
1 - create a const id. 2 - set id in object. 3 - save
createEvent(set){
const id = this.firestore.createId();
set.id = id;
return this.firestore.doc(`users/${id}`).set(ev);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With