Parse ember Rest适配器hasMany关系船ember-parse-adapter

时间:2013-12-13 16:02:53

标签: ember.js parse-platform

您好我无法在解析ember适配器中获得hasMany关系,这是我的代码。

   var newpost = this.store.createRecord('post', {
    text: 'mypost',
});
newpost.save().then(function () {
    var newcomment = this.store.createRecord('comment', {
        text: 'mycomment'
    });
    newcomment.set('post', this.store.find('post', newpost));
    newcomment.save();
})

我的网址查询参数在chrome

中如下所示
    where[$relatedTo][object][__type]:Pointer
where[$relatedTo][object][className]:Post
where[$relatedTo][object][objectId]:2KdEkYmOGX
where[$relatedTo][key]:comments

我收到此错误

{"code":102,"error":"wrong type of relation.  Expecting: , but recieved: Comment"}

我的模特很基本 交

import ParseModel from 'appkit/models/parsemodel';

var post = ParseModel.extend({
  text: DS.attr('string'),
  comments : DS.hasMany( 'comment', { async : true } )
});

export default post;

评论模型

import ParseModel from 'appkit/models/parsemodel';

var comment = ParseModel.extend({
  text: DS.attr('string'),
  post : DS.belongsTo( 'post' )
});

export default comment;

0 个答案:

没有答案