gpt4 book ai didi

Firebase:如何为嵌套字段添加索引?

转载 作者:行者123 更新时间:2023-12-02 19:16:28 31 4
gpt4 key购买 nike

我有一个 locations-orders 表,如下所示:

{
"0BW3H9T3R7HJB" : {
"orders" : {
"01750ea0-4980-4bc4-58b2-988c02324e671478636582396" : {
"created_at" : 1478636560000,
},
"01750ea0-4980-4bc4-58b2-988c02324e671478636582483" : {
"created_at" : 1478636560000,
}
}
}

每个位置订单节点都有一个带有多个键/对象的orders节点。这些对象上有一个 created_at 字段。

我将此添加到我的数据库规则中:

{
"rules": {
".read": true,
".write": true,
"users": {
".indexOn": "merchantId"
},
"merchants": {
".indexOn": "locations"
},
"locations-orders": {
".indexOn": ["orders/created_at"]
}
}
}

但是,Firebase 仍然提示我缺少索引:

Using an unspecified index. Consider adding ".indexOn": "created_at" at /locations-orders/1JS53G0TT5ZQD/orders to your security rules for better performance

我应该运行一些东西来创建索引吗?还是写错了?

===更新===

我更改了文件以查看:

{
"rules": {
".read": true,
".write": true,
"users": {
".indexOn": "merchantId"
},
"merchants": {
".indexOn": "locations"
},
"locations-orders": {
"$location_id": {
".indexOn": ["orders/created_at", "orders/status_updated_at"]
}
}
}
}

但我仍然收到相同的警告:

Using an unspecified index. Consider adding ".indexOn": "created_at" at /locations-orders/1JS53G0TT5ZQD/orders to your security rules for better performance

最佳答案

如果查看数据结构,/location-order/$orderId 下没有 orders/created_at

{
"rules": {
".read": true,
".write": true,
"users": {
".indexOn": "merchantId"
},
"merchants": {
".indexOn": "locations"
},
"locations-orders": {
"$someid": {
".indexOn": ["orders/created_at"]
}
}
}
}

关于Firebase:如何为嵌套字段添加索引?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40511866/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com