Ember.js array as model's property

前端 未结 3 916
我寻月下人不归
我寻月下人不归 2021-02-07 05:55

Cheers! I have some model, and one attribute of it is an array, but for some reasons (I use mongoDB on the server and it\'s problem with embedded models and ember-data) I can\'t

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-07 06:17

    I found that actually you can have array properties out of the box by just not specifying a type.

    #coffeescript
    
    AskuWhiteLabel.SomeModel = DS.Model.extend
        some_ids: DS.attr()
    

    I'm using this, and when I do this

    myModel.set('some_ids', [1,2,3])
    myModel.save()
    

    The payload to the server is indeed my array as is.

提交回复
热议问题