更新云 Firestore 中的字段键。

huangapple go评论58阅读模式
英文:

Update field key in cloud firestore

问题

可以像这样更新字段:

firestore.collection("Users").document(user).update("key", "value");

但我想要做相反的事情,更新 "key" 本身,而不是它的值。例如,将 key: value ---> key2: value

这是否可能?

谢谢。

英文:

Updating a field can be done like

firestore.collection("Users").document(user).update("key", "value");

but i want to do the opposite. updating "key" itself. not it's value. for example key: value ---> key2: value

Is it possible?
<br>
Thanks

答案1

得分: 2

你所询问的是不可能的。但是,您可以通过首先通过键获取值,然后将值存储在变量中来实现这一点。之后,您可以添加一个新的记录。因此,值将保持不变,但键将被更新。
希望您明白我想说的是什么。

英文:

What you are asking is not possible. But you can achieve this by getting the value first by the key, then store the value in a variable. After that you can add a new record. So the value will be same, but key will be updated.
I hope you understood what I'm trying to say.

huangapple
  • 本文由 发表于 2020年7月31日 17:51:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/63189538.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定