Good day. The push method of the store class is not necessary. It is very rarely used. It is used when, for example, an adapter / serializer is written. And in general, if I'm not mistaken, the push method takes an argument in the form of an object in json-api format. You should have something like this:
// app/models/post.js export default DS.Model.extend({ autor: DS.attr("string"), body: DS.attr("string"), publish: DS.attr("date"), title: DS.attr("string"), category: DS.belongsTo("category") }); // app/models/category.js export default DS.Model.extend({ name: DS.attr("string"), path: DS.attr("string"), posts: DS.hasMany("post") })
And in any place (route) you write those. start working
// создаете post например так let post = this.store.createRecord('post', { autor: "Vasya", body: "Body", publish: new Date(), title: "Title", }); // допустим сохраним на сервере post.save(); // затем создадим category let category = this.store.createRecord('category', { name: "Технологии", path: "Tech" }); category.get("posts").pushObject(post); category.save();
Something like this. Somewhere could of course be wrong.
Links: https://guides.emberjs.com/v2.4.0/models/relationships/ http://emberjs.com/api/data/classes/DS.Model.html#stq=&stp=0