Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
150
rated 0 times [  156] [ 6]  / answers: 1 / hits: 20826  / 12 Years ago, thu, february 14, 2013, 12:00:00

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 do somthing like this:



App.Foo = DS.Model.extend({
...
numbers: DS.hasMany('App.Bar')
)};

App.Bar = DS.Model.extend({
...
number: DS.attr('number')
});


I need something like this:



App.Bar = DS.Model.extend({
numbers: DS.attr('array')
});


But there is no array type of attributes in ember-data, how to be?


More From » ember.js

 Answers
14

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.


[#80220] Wednesday, February 13, 2013, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mitchellg

Total Points: 235
Total Questions: 117
Total Answers: 106

Location: Fiji
Member since Wed, Jul 14, 2021
3 Years ago
;