在education_qualification对象里面生成随机密钥我想得到那个密钥,怎么可能? 我试图更新该密钥,但我只获得了education_qualification而不是内部密钥。
create(model, bankDetails, currentAddress, permanentAddress, education) {
const obj = this.employees.push(model);
obj.update({
id: obj.key,
bank_details: bankDetails,
current_address: currentAddress,
permanent_address: permanentAddress,
},
(error) => {
const edu = obj.child('/education_qualification/');
for (let i = 0; i <= education.length; i++) {
edu.push(education[i]);
edu.update({
id: edu.key,
});
}
});
}
答案 0 :(得分:-1)
Push返回数据库引用。
这意味着获取密钥,您可以执行以下操作:
create(model, bankDetails, currentAddress, permanentAddress, education) {
const obj = this.employees.push(model);
obj.update({
id: obj.getKey(),
bank_details: bankDetails,
current_address: currentAddress,
permanent_address: permanentAddress,
},
(error) => {
const edu = obj.child('/education_qualification/');
for (let i = 0; i <= education.length; i++) {
edu.push(education[i]);
edu.update({
id: edu.key,
});
}
});
}