要将嵌套集合包含到Firebase中的profile中,可以按照以下步骤进行操作:
add()
方法向集合中添加文档。以下是一个示例代码,演示如何将嵌套集合包含到Firebase中的profile中:
// 获取当前用户的唯一标识符
const userId = firebase.auth().currentUser.uid;
// 在"profiles"集合中创建一个文档
firebase.firestore().collection("profiles").doc(userId).set({
name: "John Doe",
age: 25
});
// 在"profile"子集合中添加嵌套的集合
firebase.firestore().collection("profiles").doc(userId).collection("profile").add({
address: "123 Main St",
city: "New York",
state: "NY"
});
这样,你就可以将嵌套的集合包含到Firebase中的profile中了。
上一篇:包括前N行过滤匹配项。