Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase - push an object in a nested list of objects

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:

enter image description here

like image 303
AngularM Avatar asked Dec 06 '25 05:12

AngularM


1 Answers

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);
like image 171
David East Avatar answered Dec 08 '25 20:12

David East