0

How can I get the document ID and store it in field, such as the document ID marked in red, and store in post_pid

enter image description here

Ezlo
  • 13
  • 1
  • 6

1 Answers1

0

You can do something like this while adding your data.

    const postDocRef=firebaseClient.firestore().collection('post_details').doc();
    await postDocRef.set({
      post_pid: postDocRef.id,
      // ....rest of your data
    });

We get a document reference first and then we get the id property.

wick3d
  • 1,164
  • 14
  • 41