Skip to main content
added 16 characters in body
Source Link
Umaiz Khan
  • 1.2k
  • 4
  • 25
  • 71

I need to save the document id in collection. Mean when user save data it will also save the document id with data. Can any one please tell how can i do this. Thanks :)

  create() {
     // the user details are updated in firebase user list
     this.groupDetails = {
       groupname: this.Name,
       description: this.description,
       members: this.checked,
       messages: [],
       createdId: this.user.userId,
       createrName: this.user.username
     }
     console.log(this.groupDetails);
    // details are submitted to creatGroup function from groupProvider
     this.messageService.createGroup(this.groupDetails).then(resp => {
      console.log(resp);
      this.toast.show("Group Created");
      this.router.navigate(["/home"]);
     });

   }

  createGroup(groupDetails) {
    return this.angularFirestore.collection('Groups').add(groupDetails);
  }

I need to save the document id in collection. Mean when user save data it will also save the document id with data. Can any one please tell how can i do this. Thanks :)

  create() {
     // the user details are updated in firebase user list
     this.groupDetails = {
       groupname: this.Name,
       description: this.description,
       members: this.checked,
       messages: [],
       createdId: this.user.userId,
       createrName: this.user.username
     }
     console.log(this.groupDetails);
  // details are submitted to creatGroup function from groupProvider
  this.messageService.createGroup(this.groupDetails).then(resp => {
    console.log(resp);
    this.toast.show("Group Created");
    this.router.navigate(["/home"]);
  });

 }

  createGroup(groupDetails) {
    return this.angularFirestore.collection('Groups').add(groupDetails);
  }

I need to save the document id in collection. Mean when user save data it will also save the document id with data. Can any one please tell how can i do this. Thanks :)

  create() {
     // the user details are updated in firebase user list
     this.groupDetails = {
       groupname: this.Name,
       description: this.description,
       members: this.checked,
       messages: [],
       createdId: this.user.userId,
       createrName: this.user.username
     }
     console.log(this.groupDetails);
    // details are submitted to creatGroup function from groupProvider
     this.messageService.createGroup(this.groupDetails).then(resp => {
      console.log(resp);
      this.toast.show("Group Created");
      this.router.navigate(["/home"]);
     });

   }

  createGroup(groupDetails) {
    return this.angularFirestore.collection('Groups').add(groupDetails);
  }
Source Link
Umaiz Khan
  • 1.2k
  • 4
  • 25
  • 71

Ionic 4 firestoe how to save id in data?

I need to save the document id in collection. Mean when user save data it will also save the document id with data. Can any one please tell how can i do this. Thanks :)

  create() {
     // the user details are updated in firebase user list
     this.groupDetails = {
       groupname: this.Name,
       description: this.description,
       members: this.checked,
       messages: [],
       createdId: this.user.userId,
       createrName: this.user.username
     }
     console.log(this.groupDetails);
  // details are submitted to creatGroup function from groupProvider
  this.messageService.createGroup(this.groupDetails).then(resp => {
    console.log(resp);
    this.toast.show("Group Created");
    this.router.navigate(["/home"]);
  });

 }

  createGroup(groupDetails) {
    return this.angularFirestore.collection('Groups').add(groupDetails);
  }