Firebase - 在对多个节点进行更新/扇出时设置优先级 [英] Firebase - set priority when doing an update/fanout to several nodes
问题描述
pre $ firebaseRef.update(
/ some / node /:value,
/ some / other / node:other value
])
如果我想同时在/ some / other / node设置节点的优先级。那可能吗?例如:
firebaseRef.update([
/ some / node /:value,
/ some / other / node:{
value:other value,
priority:0 - Date.now()
}
])
你几乎知道了,magic属性被命名为 .priority
:
firebaseRef.update([
/ some / node /:value,
/ some / other / node:{
value:other value,
.priority:0 - Date.now()
$ b $ p $注意到并没有太多的原因(如reversedTimestamp:0 - Date.now()
)将会完成相同的操作,隐藏/魔法也会减少。
更新
看来你想要更新节点的值,而不是一个名为value的子节点。 (原始)价值和优先权,使用:
pre $ firebaseRef.update(
/ some / node /:value,
/ some / other / node:{
.value:other value,
.priority:0 - Date.now()
}
]);
I'm writing to several parts/nodes of my Firebase database in one update. Is it possible to set the priority of a node when doing this? Example:
firebaseRef.update([
"/some/node/": "value",
"/some/other/node": "other value"
])
What if I want to set the priority of the node at "/some/other/node" at the same time. Is that possible? Something like:
firebaseRef.update([
"/some/node/": "value",
"/some/other/node": {
value: "other value",
priority: 0 - Date.now()
}
])
You almost got it, the "magic" property is named .priority
:
firebaseRef.update([
"/some/node/": "value",
"/some/other/node": {
value: "other value",
".priority": 0 - Date.now()
}
]
Note that there aren't really a lot of reasons to use priorities anymore in Firebase. Adding a normally named property (e.g. "reversedTimestamp": 0 - Date.now()
) will accomplish the same and is less hidden/magic.
Update
It seems you want to update the node's value, not a child named value. To set the (primitive) value and priority in one go, use:
firebaseRef.update([
"/some/node/": "value",
"/some/other/node": {
".value": "other value",
".priority": 0 - Date.now()
}
]);
这篇关于Firebase - 在对多个节点进行更新/扇出时设置优先级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!