Reputation: 939
I can't seem to find anywhere in the Web/Javascript docs anything about saving Dates to the Firestore. In Swift
, I create a variable using NSDate
and then Firebase is able to store that as a date object in the database. Is there similar functionality in Node.js? Can I use the date-and-time package or is there native support for Dates in Node.js?
Upvotes: 3
Views: 5272
Reputation: 598728
From the Firestore documentation on saving data of supported types:
var docData = { stringExample: "Hello world!", booleanExample: true, numberExample: 3.14159265, dateExample: admin.firestore.Timestamp.fromDate(new Date("December 10, 1815")), arrayExample: [5, true, "hello"], nullExample: null, objectExample: { a: 5, b: { nested: "foo" } } }; db.collection("data").doc("one").set(docData).then(function() { console.log("Document successfully written!"); });
Upvotes: 14