I got an Appscript created for Google sheets to pull my Firestore database into Google Sheets on command. However, its pulling data with "StringValue" included in the data as well. How do I remove this? (see screenshots)
function onOpen() {
SpreadsheetApp.getUi().createMenu('?? Firestore').addItem('Import DB', 'importFromFirestore').addToUi();
}
// took my key out for obvious reasons. Replaced with XXXXXXXX - I know its right b/c it pulls the right data
function getFirestore() {
return FirestoreApp.getFirestore('XXXXXX', 'XXXXXXX', 'XXXXXXXX');
}
function importFromFirestore() {
// 1. Get a Firestore insance
const firestore = getFirestore();
// 2. Get a collection from Firestore
const allDocuments = firestore.getDocuments('scores').map(function(document) {
return document.fields;
});
// 3. Get the first document from the collection
const first = allDocuments[0];
const columns = Object.keys(first);
const sheet = SpreadsheetApp.getActiveSheet();
sheet.appendRow(columns);
// 4. Turn each document into an array to be appended to the sheet
allDocuments.forEach(function(document) {
const row = columns.map(function(column) {
return document[column];
});
sheet.appendRow(row);
});
}