I have a simple node script I run to update data in a Firestore database. I used it a couple of hours ago, worked fine. Got dinner, came back, and now I get this error when I run it:
node ./json-to-firestore.js
The behavior for Date objects stored in Firestore is going to change AND YOUR APP MAY BREAK. To hide this warning and ensure your app does not break, you need to add the following code to your app before calling any other Cloud Firestore methods:
const firestore = new Firestore(); const settings = {/* your settings... */ timestampsInSnapshots: true};
firestore.settings(settings);
The example provided in the error does not apply to my case. I've looked for help on this issue, but all the posts seem to be angular-specific. This is all I'm trying to do:
var admin = require("firebase-admin");
var serviceAccount = require("./service-key.json");
const data = require("./occ-firestore.json");
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "xxxxxxxxxxx"
});
data && Object.keys(data).forEach(key => {
const nestedContent = data[key];
if (typeof nestedContent === "object") {
Object.keys(nestedContent).forEach(docTitle => {
admin.firestore()
.collection(key)
.doc(docTitle)
.set(nestedContent[docTitle])
.then((res) => {
console.log("Document successfully written!");
})
.catch((error) => {
console.error("Error writing document: ", error);
});
});
}
});
I execute this script by running:
node ./json-to-firestore.js
I'm running NodeJS 8.11.3.
I checked Google's docs and there's no reference to this new behavior.
Can someone provide me with a suggestion? Thanks in advance!