grahamearley / FirestoreGoogleAppsScript

A Google Apps Script library for accessing Google Cloud Firestore.

Home Page:http://grahamearley.website/blog/2017/10/18/firestore-in-google-apps-script.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

tom-alder opened this issue · comments

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: #78

Wondering if this may be impossible for a similar reason?

Thanks!

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.