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

Exporting data from firebase to google sheet's data have data type with the value #123

Closed scy0334 closed 3 years ago

scy0334 commented 3 years ago

Minimal Code to Reproduce the Problem


function getGemExchange() {
  // 1. Get a Firestore instance
  const firestore = FirestoreApp.getFirestore(email, key, projectId);

  // 2. Get a collection from Firestore
  const userDocuments = firestore.getDocuments('gemExchangeRequests').map(document => document.fields)

  // 3. Get the first document from the collection 
  const first = userDocuments[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
  userDocuments.forEach(document => {
    const row = columns.map(column => document[column])
    sheet.appendRow(row)
  })
}

Explain the Problem in Detail

0

I'm using Google App Scripts and Firestore GoogleAppScripts for data fetching from firestore to google sheet as explained on this library.

Here's my code.

It all works fine except the values have its data type with it.

스크린샷 2021-05-28 오후 4 03 50

So I want to get rid of data types such as "stringValue", "integerValue" or "doubleValue" on my Google Spreadsheet.

For example, I want "PENDING" for the "status" column, not "{stringValue=PENDING}"

What should I do in this case?

Other Comments

Library Version:
scy0334 commented 3 years ago

Solved. Used Object.values() => Things didn't work because I had to unwrap the array values after Object.values(). My bad on this.