Non-persistent attributes in EmberJS

后端 未结 4 1231
时光取名叫无心
时光取名叫无心 2021-02-13 19:48

Does anyone know of a way to specify for an Ember model an attribute which is not persisted?

Basically, we\'re loading some metadata related to each model

4条回答
  •  天涯浪人
    2021-02-13 20:18

    Following this answer, to prevent a field from being serialized, override the default serializer for your model:

    In app/serializers/person.js:

    export default DS.JSONSerializer.extend({
      attrs: {
        admin: { serialize: false }
      }
    });
    

    See here for the source PR. This solution works in Ember Data 2, and should work in older versions as well.

提交回复
热议问题