grahamearley / FirestoreGoogleAppsScript

A Google Apps Script library for accessing Google Cloud Firestore.
http://grahamearley.website/blog/2017/10/18/firestore-in-google-apps-script.html
MIT License
648 stars 109 forks source link

Setting document reference as a field #109

Closed ShreeniwasIyer closed 4 years ago

ShreeniwasIyer commented 4 years ago

Explain the Problem in Detail

I have two sheets - one containing "tips" and the other referring to the tips through an id. When I write this to firestore, I want tips to be in a separate collection and questions to be in a separate collection with a reference field to the corresponding tip document.

The current library allows me to only put the field as a string (where I have tried sending in the full document url, or relative document URL), but it is set as a string and not as a document reference. Does anyone know how to set reference fields in the current API?

Other Comments

Library Version:
LaughDonor commented 4 years ago

I guess it's not better documented. Reference values must take on the format of:

projects/my-project-name/databases/(default)/documents/my-collection-name/my-document-name/my-optional-subcollection/my-optional-subdocument

Where all the my-* sections of the path should be replaced. The subcollection/subdocuments are optional and repeatably nested.

ShreeniwasIyer commented 4 years ago

That worked! Thank you.