我正在使用Firestore,我想删除特定对象中的字段.我可以删除文档中的字段,这要归功于:
fieldName: firebase.firestore.FieldValue.delete()
Run Code Online (Sandbox Code Playgroud)
但如果我有一个像这样的对象:
songList {
songName1: "HelloWorld",
songName2: "AnotherSong",
songName3: "andTheLastOne"
}
Run Code Online (Sandbox Code Playgroud)
为了删除字段songName3,我将无法执行以下操作:
songList.songName3: firebase.firestore.FieldValue.delete()
Run Code Online (Sandbox Code Playgroud)
有没有办法删除对象内的字段?或者我应该删除整个对象,在没有第3个字段的情况下重建它并保存它?
提前致谢,
我正在尝试在我的项目中实现Firestore。我现在正在做的只是实现它并读取一些数据,但是标题中出现错误:
由于访问控制检查,XMLHttpRequest无法加载https ://firestore.googleapis.com/google.firestore.....。
我使用以下内容:
// Initialize Firebase
var config = {
apiKey: "xxx",
authDomain: "xxx",
databaseURL: "xxx",
projectId: "xxx",
storageBucket: "xxx",
messagingSenderId: "xxx"
};
firebase.initializeApp(config);
// Initialize Cloud Firestore through Firebase
var db = firebase.firestore();
var docRef = db.collection("users");
docRef.get().then(function(querySnapshot) {
querySnapshot.forEach(function(doc) {
//alert(doc.data().born);
});
})
.catch(function(error) {
console.log("Error getting documents: ", error);
});
Run Code Online (Sandbox Code Playgroud)
我尝试检索数据的部分导致错误(docRef.get()...)
您知道为什么会发生此错误吗?
提前致谢,