【发布时间】:2017-09-16 19:35:55
【问题描述】:
所以我使用 Firebase 实时数据库作为我的后端,但我遇到了一个问题,这可能有一个非常简单的解决方案..
我想将一些信息推送到数据库,但就目前而言,它不是推送一个 new 对象,而是简单地更新数据库..
这是我的做法:
firebase.database().ref('users/' + uid + '/entries/'+$scope.todos.id+'/trackers/'+$scope.currTrack.id).update({
note: individual.note,
value: individual.value
});
所以这很简单,但这就是数据库中正在发生的事情:
...
-KuB-l8OX9zxGYuGw_EK //this is $scope.currTrack.id
note: "the note",
value: "the value"
所以不是创建一个新的递增整数键,而是将它放在 id 的正下方..
我希望发生的是:
...
-KuB-l8OX9zxGYuGw_EK //this is $scope.currTrack.id
0 //incrementing integer key
note: "the note",
value: "the value"
1
note: "the 2nd note",
value: "the 2nd value"
我做错了什么?我正在使用update,但set 的工作方式也一样..
有什么想法吗?谢谢!
【问题讨论】:
标签: javascript angularjs oop firebase firebase-realtime-database