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

Is it possible to add Google Sheets data as an array field in Firestore? #133

Closed tom-alder closed 2 years ago

tom-alder commented 2 years ago

Explain the Problem in Detail

Is it possible to add data in Google Sheets as an array field-type in Firestore?

In the Firestore docs, it has an example of how to write an array data type: https://cloud.google.com/firestore/docs/manage-data/add-data

const docData = { arrayExample: [5, true, "hello"], };

If I have a cell with data [5, true, "hello"] is it possible for me to store that as an array in Firestore?

I have seen that a similar request around appending to a Firestore array field was marked as invalid due to REST API limitations: https://github.com/grahamearley/FirestoreGoogleAppsScript/issues/78

Wondering if this may be impossible for a similar reason?

Thanks!

LaughDonor commented 2 years ago

Sorry for checking this out late, @tom-alder.

This sounds like an implementation detail when utilizing this library. You wouldn't be able to directly take the contents of a cell and push it to Firebase, or it'll just store it as a string. You'll want to convert those values into an array yourself before pushing it to Firebase.