【发布时间】:2018-04-14 11:40:49
【问题描述】:
我正在尝试将数据添加到我的 firebase 数据库。但是如何自动将下一个可用 ID 分配给我要发送的数据?
但是,每当我尝试添加数据并将 ID 留空时,我都会得到以下结果:
当我在代码中手动添加 ID 时,它确实有效!但是我怎样才能让它为我自动完成呢?
这是我的消防服务.ts
create(id: string, description: string, kind: string, name: string, preparation: string, img: string, ingredients: string) {
this.db.object('gerechten/'+id).update({
id:id,
description: description,
kind: kind,
name: name,
preparation: preparation,
img: img,
ingredients: ingredients
})
}
还有我的 create.ts
gerecht = {
description: "",
kind: "",
name: "",
prepartion: "",
ingredients: "",
id: "",
img: ""
}
---------
create() {
this.db.create(this.gerecht.id, this.gerecht.description, this.gerecht.kind, this.gerecht.name, this.gerecht.prepartion, this.gerecht.img, this.gerecht.ingredients)
this.navCtrl.push(HomePage)
}
【问题讨论】:
标签: firebase ionic-framework firebase-realtime-database ionic3