Firebase:更新密钥? [英] Firebase: Update key?
本文介绍了Firebase:更新密钥?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
{
43268jfjn7983-347983:
{
标题:'hello world',
时间:'1000'
}
$ b $ p
$ b 如上所述,我只想更新 43268jfjn7983 -347983
到其他的东西,这是可能的firebase?
解决方案没有办法改变现有节点的关键。
所以,我会去的:
$ $ $ $ $ $ $ c $ var ref =新的Firebase('https://my.firebaseio.com/');
var child = ref.child('43268jfjn7983-347983');
child.once('value',function(snapshot){
ref.child('somethingElse')。set(snapshot.val());
child.remove();
});
{
43268jfjn7983-347983:
{
title: 'hello world',
time: '1000'
}
}
As above, I just want to update 43268jfjn7983-347983
to something else, is this possible in firebase?
解决方案
There is no way to change the key of an existing node.
So instead I'd go for:
var ref = new Firebase('https://my.firebaseio.com/');
var child = ref.child('43268jfjn7983-347983');
child.once('value', function(snapshot) {
ref.child('somethingElse').set(snapshot.val());
child.remove();
});
这篇关于Firebase:更新密钥?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文