Comments (12)
The newest version of the localstorage-adapter is meant for Ember Data beta 5 and onwards. I would consider upgrading. Also make sure you have the newest version of master.
from ember-localstorage-adapter.
i tried with latest version of ember-data(i.e. ember data beta 6) and even latest version of master but having same problem
is this a bug or some conceptual mistake by me??
from ember-localstorage-adapter.
@oblongta I believe that if reload
is broken, it is in Ember Data rather than in the adapter. Nonetheless, try doing company.set('person', person)
instead of using it in createRecord()
.
Also, this is wrong:
// you need to use the store to create a record,
// not a model (which is an array in this case)
var a=model.get('employees');
a.createRecord();
Do this instead
var person = this.store.createRecord('person', {
name: 'pqr',
department: 'lmn',
});
person.save().then(function(person) {
person.set('company', model);
person.save();
});
I ask you to do this because I recently had problems with embedding relations in createRecord()
.
from ember-localstorage-adapter.
ok then how do i add person to a company which has hasMany relation with the person??
And The problem is not creating a record or saving it.
The records are created and they are even getting saved but the relation between person and company gets lost i.e. hasMany arrays content gets wiped out .
It is related to the issue mentioned below as i think:
#23
And my code is update version of this jsbin if you look closely:
http://jsbin.com/oKuPev/72/edit
from ember-localstorage-adapter.
This is how I do it for a project of mine:
var order = this.get('model');
var user = App.get('currentUser');
order.set('user', user);
order.save().then(function(o) {
user.get('orders').addObject(order);
user.save().then(function(u) {
this.transitionToRoute('order.handle', order, getDateString());
});
});
Don't get confused with my use of App.get('currentUser') just think of it as your person. You could potentially have created this person already. But the above code saves the records and maintains the hasMany relationship.
My relationships are:
App.User = DS.Model.extend({
username: DS.attr('string'),
password: DS.attr('string'),
orders: DS.hasMany('order')
});
App.Order = DS.Model.extend({
navision: DS.attr('number'),
closed: DS.attr('boolean'),
user: DS.belongsTo('user'),
hours: DS.hasMany('hour'),
materials: DS.hasMany('material'),
services: DS.hasMany('service')
});
from ember-localstorage-adapter.
Thanxx,
I will look and hope it to get working.
can you tell me whats wrong in this implementation:
http://jsbin.com/oKuPev/72/edit
and my error is same as #23 as it seems to me.
Any method to overcome that
from ember-localstorage-adapter.
I tried this and getting the same problem:
App.ApplicationController=Ember.ArrayController.extend({
add:function(){
var c= this.store.createRecord('company',{
name:'abc',
turnover:'lmn'
});
var p=this.store.createRecord('person',{
name:'xyz',
department:'pqr'
});
p.save().then(function(p){
p.set('company',c);
p.save().then(function(p){
c.get('employees').addObject(p);
c.save();
});
});
}
});
from ember-localstorage-adapter.
this is screen shot before reloading.
You can see person attributes in the template namely xyz and pqr.
Also,in properties tab you see content property has that person record in the array.
However on reloading i get this:
Now the content property doesnt contain that person record in array and hence no attributes of person are rendered in template.
But however on checking local storage i find that the person exists in local storage:
from ember-localstorage-adapter.
Ah, now I remember why. I'll have to take a look at it. But try using findAll instead of find.
from ember-localstorage-adapter.
no findAll doesnt solve the issue.
Is it issue with ember data/local adapter or some conceptual error by me??
from ember-localstorage-adapter.
Okay, I know now. As the README states:
Include localstorage_adapter.js
in your app and then like all adapters:
App.ApplicationSerializer = DS.LSSerializer.extend();
App.ApplicationAdapter = DS.LSAdapter.extend({
namespace: 'yournamespace'
});
In the code you linked initially there is no ApplicationSerializer. This serializer handles all the relationships, so without it you're never going to get the relationships.
I will have a closer look at find() since I still expect it to be a little buggy, so use findAll for now.
from ember-localstorage-adapter.
Thanks for help.
it solved my problem
from ember-localstorage-adapter.
Related Issues (20)
- Checkout project and run tests: 47 tests. 2 passed, 45 failed HOT 4
- findAll returns empty array always HOT 2
- store.find('model-type', { prop: value} ) no longer working in 0.5.4 HOT 6
- Uncaught TypeError: Cannot read property 'typeKey' of undefined HOT 4
- support for > Ember Data 1.0.beta.16 HOT 6
- unloadAll() doesnt work HOT 2
- New Release HOT 3
- Are query() queryRecord() supported? HOT 1
- use begin/endPropertyChanges in findMany
- relationships in "new" state should not be pushed to LS
- Ember data 2.3+ does not work with this addon HOT 21
- sessionStorage support HOT 3
- FastBoot-ness
- Relationships to a model using another adapter HOT 1
- Resolve no results instead of rejecting the promise HOT 2
- After a failed .findRecord, it is impossible to create a record with the same id HOT 2
- Unable to fetch with .findAll('user') HOT 1
- Upgrade ember-cli-babel & ember-runtime-enumerable-includes-polyfill to remove deprecation warning HOT 6
- Fix use of deprecated .copy method
- Push new version
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ember-localstorage-adapter.