javascript - Ember.js : How to find records that do NOT have a property set? -



javascript - Ember.js : How to find records that do NOT have a property set? -

i have bunch of records "belongsto" other records. (different models, typical 1-n relationship.) how can phone call find on model find have no belongs-to association?

something like:

app.thing = ds.model.extend({ other: ds.belongsto( 'app.other' ), someattr: ds.attr('string') }); app.thing.find({ other: null });

edit:

louiscoquio's solution didn't work me. thought filter in controller.

here's how seek it:

app.thingsasidecontroller = ember.arraycontroller.extend({ unassigned: function() { homecoming this.filterproperty('other'); }.property('content.@each') });

this works fine if filter someattr cannot filter relationship.

i guess question is: property name belongsto association?

edit, works:

this works, i'm unhappy it:

app.thingsasidecontroller = ember.arraycontroller.extend({ unassigned: function() { homecoming this.filter(function(item, index, enumerable){ var belongstoother = false; var otherthings = app.otherthing.find(); otherthings.foreach( function( otherthing ){ otherthing.get('things').foreach( function( otherthingthing ) { if( otherthingthing.id === item.id ) { belongstoother = true; } }); }); homecoming !belongstoother; });

i've been reading ember-data source can't find out how query belongs-to association of record.

you can utilize filter method available ds.model classes:

var filteredthings = app.thing.filter(function(thing) { homecoming thing.get('other') === null; });

it returns array contains app.thing returned true in callback pass.

as documentation says:

it returns live recordarray remains date new records loaded store or created locally.

javascript ember.js

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -