ember.js - How to I specify a primary key for Ember Data? -


my server uses sensorid primary key on sensor model. i've tried following

app.sensorserializer = ds.restserializer.extend({   primarykey: "sensorid" }); 

based on see in this test, it's not working. i'm getting error:

error while loading route: error: no model found '0' 

i'm using custom adapter. response jsonp:

jquery203041337518650107086_1397489458691([{"sensorid":1,"address":"xxx, yyy","latitude":"nnnn","longitude":"mmmm"... 

but when inspect data gets returned, it's normal array:

// app.sensoradapter findall: function(store, type, sincetoken) {   var url = 'http://blahblahblah/?callback=?';   var query = { since: sincetoken };    return new ember.rsvp.promise(function(resolve, reject) {     jquery.getjson(url, query).then(function(data) {       debugger;       // data.foreach(function(s) {       //   s.id = +s.sensorid;       // });       ember.run(null, resolve, data);      }, function(jqxhr) {       jqxhr.then = null; // tame jquery's ill mannered promises       ember.run(null, reject, jqxhr);     });   }); 

what correct syntax ember data 1.0.0-beta.7?

try this:

app.adapter.map('app.sensor', {   primarykey: 'sensorid' }); 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -