ember-data

Difference between this.get('model') and modelFor

不想你离开。 提交于 2019-12-21 09:27:11
问题 I am quite new to ember and don't really get the difference between two types of syntax. Where and in which situations should i use one or another. I.e. Which one is more suitable for usage in Routes and which one for Controllers. this.get('model') As opposed to this.modelFor('artists/show') 回答1: this.get('model') //controller call this.modelFor('someRoute') //route call In Ember, a routes setupController hook by default performs this one line of code: setupController: function(controller,

How to debug Ember data's find in the console

孤街浪徒 提交于 2019-12-21 04:56:48
问题 With this post, I learned that I can use find in the console. But I'm having some problems using this to look up the data in my litte jsbin Ember.js with Ember Data and LSAdapter App here. Please add some orgs Please open your chrome console to see more details. Please type in App. container .lookup('store:main').find('org').toArray() Why does it show an empty array ??? Thank you so much for helping out 回答1: It's because find returns promises now App.__container__.lookup('store:main').find(

is handling custom server side errors in ember-data when saving model possible

与世无争的帅哥 提交于 2019-12-21 04:52:09
问题 Is there proper way to handle custom error when saving a model? To give an example, lets say I have a model with just two properties "name" and "value". And when I do : var myModel = this.get('store').createRecord('myModel', {"name": "someName", "value": "someValue"}); myModel.save().then(function() { //if success //server responded with {"myModel:{"id":1,"name":"someName","value":"someValue"}"} },function() { //if failure //server responded with {"error":"some custom error message"} //BUT

Ember model reloading in interval

一世执手 提交于 2019-12-21 03:34:11
问题 I have a User model, which has latitude and longitude properties, which are used to show current user location on map. App.User = DS.Model.extend({ firstName: DS.attr('string'), lastName: DS.attr('string'), email: DS.attr('string'), jobs: DS.hasMany("App.Job"), latitude: DS.attr('number'), longitude: DS.attr('number'), measuredAt: DS.attr('date'), }); What is the best way to autoupdate latitude and longitude properties from server every given interval? Does ember-data support this kind of use

Delete JSON root element for POST/PUT operations in Ember Data

旧城冷巷雨未停 提交于 2019-12-21 03:28:42
问题 I'm consuming a web service that in POST/PUT verbs expects a JSON like this: { "id":"CACTU", "companyName": "Cactus Comidas para llevar", "contactName": "Patricio Simpson", "contactTitle": "Sales Agent", "address": "Cerrito 333", "city": "Buenos Aires", "postalCode": "1010", "country": "Argentina", "phone": "(1) 135-5555", "fax": "(1) 135-4892" } But Ember Data sends a JSON like this: { "customer": { "id":"CACTU", "companyName": "Cactus Comidas para llevar", "contactName": "Patricio Simpson",

emberjs Cannot clone an Ember.Object that does not implement Ember.Copyable

做~自己de王妃 提交于 2019-12-21 03:26:13
问题 I am using ember 1.3.1 and ember-data 1.0.0-beta.5. On creating new mode I get following error Assertion failed: Cannot clone an Ember.Object that does not implement Ember.Copyable Following is my model code App.myModel = DS.Model.extend({ name : DS.attr('string'), age : DS.attr('string') }); In my create route model function return Em.Object.create({}); and finally on save I do following this.store.createRecord('property', this.get('model')); Although despite the error, my backend service is

Collection of objects of multiple models as the iterable content in a template in Ember.js

ぐ巨炮叔叔 提交于 2019-12-21 02:58:07
问题 I am trying to build a blog application with Ember. I have models for different types of post - article, bookmark, photo. I want to display a stream of the content created by the user for which I would need a collection of objects of all these models arranged in descending order of common attribute that they all have 'publishtime'. How to do this? I tried something like App.StreamRoute = Ember.Route.extend({ model: function() { stream = App.Post.find(); stream.addObjects(App.Bookmark.find());

Delete associated model with ember-data

蓝咒 提交于 2019-12-20 12:31:59
问题 I have two models: App.User = DS.Model.create({ comments: DS.hasMany('App.Comment') }); App.Comment = DS.Model.create({ user: DS.belongsTo('App.User') }); When a user is deleted, it also will delete all its comments on the backend, so I should delete them from the client-side identity map. I'm listing all the comments on the system from another place, so after deleting a user it would just crash. Is there any way to specify this kind of dependency on the association? Thanks! 回答1: I use a

Architecture for data layer that uses both localStorage and a REST remote server

馋奶兔 提交于 2019-12-20 08:56:22
问题 Anybody has any ideas or references on how to implement a data persistence layer that uses both a localStorage and a REST remote storage: The data of a certain client is stored with localStorage (using an ember-data indexedDB adapter). The locally stored data is synced with the remote server (using ember-data RESTadapter). The server gathers all data from clients. Using mathematical sets notation: Server = Client1 ∪ Client2 ∪ ... ∪ ClientN where, in general, any record may not be unique to a

Architecture for data layer that uses both localStorage and a REST remote server

巧了我就是萌 提交于 2019-12-20 08:53:08
问题 Anybody has any ideas or references on how to implement a data persistence layer that uses both a localStorage and a REST remote storage: The data of a certain client is stored with localStorage (using an ember-data indexedDB adapter). The locally stored data is synced with the remote server (using ember-data RESTadapter). The server gathers all data from clients. Using mathematical sets notation: Server = Client1 ∪ Client2 ∪ ... ∪ ClientN where, in general, any record may not be unique to a