在将 javascript 对象保存到 firestore 之前,只需创建一个 Date() 实例并传递如下值new Date("December 10, 1815")
Syntax
var docData = {
stringExample: "Hello world!",
booleanExample: true,
numberExample: 3.14159265,
dateExample: 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!");
})
Cloud Firestore 支持,
日期和时间 - 时间顺序- 存储在 Cloud Firestore 中时,仅精确到微秒;任何额外的精度都会向下舍入。
Note
当查询涉及具有混合类型值的字段时,Cloud Firestore 使用基于内部表示的确定性排序。
官方链接
https://firebase.google.com/docs/firestore/manage-data/data-types https://firebase.google.com/docs/firestore/manage-data/data-types
https://firebase.google.com/docs/firestore/manage-data/add-data https://firebase.google.com/docs/firestore/manage-data/add-data