Firebase.update失败:第一个参数在属性中包含未定义的内容。

9 浏览
0 Comments

Firebase.update失败:第一个参数在属性中包含未定义的内容。

我有一个简单的Firebase函数,用于更新一些数据。然而,解释器说第一个参数在属性 'users.tester1' 中包含 "undefined"。有人可以帮忙吗?

var objify = function() {
  var rv = {};
    for (var i = 0; i < arguments.length; ++i)
      rv[arguments[i]] = rv[arguments[i+1]];
    return rv;
}
    addUser("tester1", []);
var addUser = function(name, edges){
  if(!checkIfUsernameExists(name) && !checkIfNodeNameExists(name) && !checkIfEdgeNameExists(name)){
    var time = Firebase.ServerValue.TIMESTAMP;
    //HERE: I think the error is on this line 
    refs.users.update(objify(name, "filler"));
    refs.users.child(name).set({
      "id" : time,
      "edges" : "filler"
    });
    refs.users.child(name).child("edges").update({
      "to" : "filler",
      "from" : "filler"
    });
    addNode(new Node(name, time, name));
    for(var e in edges){
      refs.users.child(name).child("edges/to").update(objify(edges[e].name, true));
      addEdge(new Edge(edges[e].name, time, edges[e].to, edges[e].arrows));
      //TODO add a "from" edge so that you know who wants to eat you
    }
    refs.users.child(name).child("edges/to").set({"filler" : null});
  } else {
    alert("user/node/edge name taken.");
  }
};

0