Ember-data and MongoDB, how to handle _id

后端 未结 9 1980
眼角桃花
眼角桃花 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:51

    Although the question is quite old but i still think my answer could help others:

    If you are using ActiveModelSerializer then you just need to do this :

    class UserSerializer < ActiveModel::Serializer
         attributes :id , :name
    end
    

    It works all fine. I am using emberjs on the front end btw.

提交回复
热议问题