【发布时间】:2018-12-06 06:16:14
【问题描述】:
我正在制作一个应用程序来获取成分,而不是显示可以用这些成分制成的食谱。食谱将存储在 fire-base 中。 我正在考虑使用的结构如下所示:
{
"description" : "Some description",
"name" : "Recipe name",
"idRecipe" : 1,
"ingredients" : {
"ingredient1" : "tomato",
"ingredient2" : "pepper",
.
.
.
"ingredient10": "cheese",
},
"numOfPersons" : 2,
}
我如何'查询'具有匹配成分的食谱,或者应该改变食谱的结构?
【问题讨论】:
-
在您当前的数据模型中,您可以轻松找到给定食谱的成分。但是,您不能有效地查询给定成分的食谱。您需要为此创建一个额外的数据结构。请在此处查看我的解释以获取更多信息:stackoverflow.com/questions/40656589/…
-
或者,看看 Cloud Firestore,它更本机地处理此类分类查询,只要您将它们存储在数组中:firebase.googleblog.com/2018/08/…
标签: database firebase firebase-realtime-database