Giter VIP home page Giter VIP logo

Comments (6)

grahamearley avatar grahamearley commented on July 26, 2024 1

Thanks for pointing this out — this is an issue specifically with the latest versions. I neglected to include all the document data in the return of the getDocuments function. It only returns the fields.

I'll add the timestamps back in soon, but in the meantime here's a workaround using the older version of the library:

If you use Version 8, the get function (when given a document path) will return all the document information, including its timestamp data and fields. The fields will be typed (e.g. a mapping to a string name: "Name" will show up in the object as name: { stringValue: "Name" } .

To unwrap the value document you get from calling FirestoreApp.get("your/document/path/here", email, key, projectid), call FirestoreApp.getFieldsFromFirestoreDocument(document).

from firestoregoogleappsscript.

grahamearley avatar grahamearley commented on July 26, 2024

@soitecOpensources In the latest library version (15), that functionality is now available! Added in this commit: eceb6de

from firestoregoogleappsscript.

LaughDonor avatar LaughDonor commented on July 26, 2024

I'm still not seeing timestamp data. That field returns null when using getDocuments().

from firestoregoogleappsscript.

grahamearley avatar grahamearley commented on July 26, 2024

@LaughDonor Are you using version 15 of the library? I just ran my tests again and saw a timestamp. Here's the code I used:

function test_readDocumentsWithTimestamp() {
  const collectionName = "timestamp_test_collection";
  
  const document1 = {
    "name": "test one!",
    "number": 1
  }
  
  const document2 = {
    "name": "test two!",
    "number": 2
  }
  
  firestore.createDocumentWithId("document1", collectionName, document1);
  firestore.createDocumentWithId("document2", collectionName, document2);
  
  const docs = firestore.getDocuments(collectionName);
  Logger.log(docs);
}

And it logged:

[
   {
      createTime=2018-05-15T00:04:56.340842Z,
      name=projects/xxxxxxxx/databases/(default)/documents/timestamp_test_collection/document1,
      updateTime=2018-05-15T00:04:56.340842Z,
      fields={
         number=1,
         name=test one!
      }
   },
   {
      createTime=2018-05-15T00:04:56.484303Z,
      name=projects/xxxxxxxx/databases/(default)/documents/timestamp_test_collection/document2,
      updateTime=2018-05-15T00:04:56.484303Z,
      fields={
         number=2,
         name=test two!
      }
   }
]

If you are using version 15 of the library, could you send the logs of the returned object from the getDocuments call?

from firestoregoogleappsscript.

LaughDonor avatar LaughDonor commented on July 26, 2024

@grahamearley Sorry, I meant the field timestamp typed data was not showing.

from firestoregoogleappsscript.

grahamearley avatar grahamearley commented on July 26, 2024

@LaughDonor Oh, I see what you're saying. Yes, there are still some unimplemented data types. I'll file an issue for getting those implemented.

from firestoregoogleappsscript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.