I am trying to set up a one-to-many relationship between a mongoDB Document and its Subdocuments. So far I git my models:
user/model.js:
export default DS.Model.extend({
name: DS.attr('string'),
age: DS.attr('number'),
calendarEntries: DS.hasMany('calendarEntries', {embedded: true})
//also tried embedded: 'always'
});
calendar-entry/model.js
export default DS.Model.Extend({
title: DS.attr('string'),
date: DR.attr('string'),
user: belongsTo('user') //Also tried without this
});
What I get from the api is:
"user": {
"_id": "56e3510e8a87920cc961faf5",
"name": "John Doe",
"age": 25,
"calendarEntries": [
{
"_id": "56e3511f8a87920cc961faf6",
"title": "Meet friends",
"date": "2016-03-13T00:54:13.442Z"
}
]
}
I also use a serializer to set the primaryKey to '_id'. The api has the End-Points /users, /users/:userid, /users/:userid/calendarEntries and /users/:userid/calendarEntries/:entryid. In other posts i read this was working and I dont get my mistake. The error message doesnt really tell me anything: "Passing classes to store methods has been removed. Please pass a dasherized string instead of undefined". Since the other posts I read are about two years old, i dont know what changed in ember-data.
Aucun commentaire:
Enregistrer un commentaire