我刚刚开始使用Fauna和FQL。如何使用在线shell将嵌套文档添加到另一个文档中?
这是我到目前为止所拥有的
users: [
{
userID: "from google",
userName: "from signup form",
userEmail: "from signup form form",
profileimgurl: "maybe from google",
accessCode: 12345,
role: "main or secondary. customer will automatically become main."
},
{
userID: "from google",
userName: "from signup form",
userEmail: "from signup form form",
profileimgurl: "maybe from google",
accessCode: 12345,
role: "main or secondary. customer will automatically become main."
}
]发布于 2021-08-25 20:44:33
Fauna将数据存储在无模式的Documents中,因此您可以在文档数据中嵌入数组或其他对象。例如,在shell中:
Create(
Collection("users"),
{
data: {
name: "Paul",
email: "paul@paul.com
address: {
country: "United States",
},
tags: ["pinball", "camping"]
}
}
)根据您需要读取和更新文档的方式,将数据保存在单独的集合中并维护与References的关系可能是合适的。
Create(
Collection("public_profiles"),
{
data: {
name: "Paul",
tags: ["pinball", "camping"]
}
}
)
{
ref: Ref(Collection("public_profiles"), "307924242117165124"),
ts: 1629918291110000,
data: { name: "Paul", tags: ["pinball", "camping"] }
}Update(
Ref(Collection("users"), "307924248572638574"),
{
data: {
tags: null,
profile: Ref(Collection("public_profiles"), "307924242117165124")
}
}
)文档有一个Social Graph example,它演示了如何创建和查询关系。
https://stackoverflow.com/questions/65512302
复制相似问题