在 Firebase 中使用用户的副本时,$conf 美元已添加到对象中,因此我无法将用户复制到新位置?



除非我在身份验证回调中访问 Firebase 用户,否则该对象会添加 $$conf,这使我无法创建用户配置文件的副本以移动到新位置。有什么办法吗?

//any variation of this doesn't seem to work except for in an auth callback
var teamRef = new Firebase('https://demo.firebaseio.com/teams/' + teamName);
var teamList = $firebase(teamRef.child('profiles'));
teamList.$set(user.uid, user);

用户对象注销到以下内容:

e {$$conf: Object, $id: "simplelogin:107", $priority: null, email: "andrey@dsrp.tv", md5_hash: "7130dfaebedd9ac16f5e5d73822b160c"…}$$conf: Object$id: "simplelogin:107"$priority: null

即使我只是抓取user.uid值,我仍然会收到错误:

   Error: Firebase.set failed: First argument  contains an invalid key ($$conf).  Keys must be non-empty strings and can't contain ".", "#", "$", "/", "[", or "]"

这让我停下了脚步。我目前正在尝试想一种方法来从身份验证回调而不是在不同的位置执行我需要做的事情。

任何想法将不胜感激。

复制同步对象是非常奇怪的。根据定义,副本要么复制所有同步方法,要么立即过时和过时。更有可能的是,您希望将用户 ID 存储在"团队"路径中并引用实际数据,以便它始终是最新的。

也就是说,要制作副本,只需调用 to JSON 即可删除 $$ 方法。Firebase 为此提供了一个实用程序:

var user = $firebase(...).$asObject();
var userCopy = $firebaseUtils.toJSON(user);
...$set(user.uid, userCopy);

最新更新