Ember-data and MongoDB, how to handle _id

后端 未结 9 1961
眼角桃花
眼角桃花 2021-02-08 17:15

I\'m using ember-data with rails and MongoDB and am having problem with the way IDs are stored in MongoDB - in a _id field.

Ember-data will use id as the default field f

9条回答
  •  感情败类
    2021-02-08 17:35

    I don't know exactly when this was added, but you can just tell Ember-Data that the primaryKey is _id:

    DS.RESTAdapter.extend({
      serializer: DS.RESTSerializer.extend({
        primaryKey: '_id'
      })
    });
    

提交回复
热议问题