5
随着angulafire
有可能将其保存到数据库之前检索记录pushid之前得到新pushid:angularfire2节能模型对象
myModelDto.key = dbRef.push().key;
// Add the myModelDto to the relative colletion
这是方便,因为我可以存储火力键的属性我模型。
现在有了angularfire2
这似乎并不可能在干净/简单方式:
constructor(private angFire: AngularFire) {
this.placeRef$ = angFire.database.list('/places');
}
insertPlace = (place: IPlace): firebase.Thenable<IPlace> => {
return this.placeRef$.push(place)
.then(item => {
place.id = item.key;
this.placeRef$.update(item.key, place)
});
所以我不知道我是否以错误的方式接近火力(希望有一个关键属性绑定到我的模型方便),还是有更好的方法将pushid添加到新添加的记录中。