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添加到新添加的記錄中。