Firebase - 在对象的嵌套列表中推送对象 [英] Firebase - push an object in a nested list of objects

查看:154
本文介绍了Firebase - 在对象的嵌套列表中推送对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Firebase - 在对象的嵌套列表中推送对象



当前的尝试:

  this.application.userUid = this.uid; 
this.application.companyUid = job.uid;
this.application.jobName = job.name;
this.application.jobDescription = job.description;
this.application.jobId = job.id;

this.refApp.child(this.uid).child(job.id).push(this.application);

目前已添加对象,但嵌套太低。它需要像列表中的第二个对象一样。

uid - > jobid - >然后是对象。



这里是我的数据库:

使用 .set(),而不是 .push() code $
$ b $ $ p $ this.refApp.child(this.uid).child(job.id).set(this 。应用);然而,如果你想用 .push()来产生一个id,那么你就可以使用
$ b> / code>您可以在数据结构中移回一级:

  this.refApp.child(this.uid ).push(this.application); 


Firebase - push an object in a nested list of objects

Current attempt:

this.application.userUid = this.uid;
this.application.companyUid = job.uid;
this.application.jobName = job.name;
this.application.jobDescription = job.description;
this.application.jobId = job.id;

this.refApp.child(this.uid).child(job.id).push(this.application);

Currently the object is added but nested too low down. It needs to be like the second object in the list.

uid --> jobid -> then the object.

Here is my database:

解决方案

Use .set(), instead of .push()

this.refApp.child(this.uid).child(job.id).set(this.application);

However, if you want to generate an id with .push() you can move back one level in the data structure:

this.refApp.child(this.uid).push(this.application);

这篇关于Firebase - 在对象的嵌套列表中推送对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆