locks / ember-localstorage-adapter Goto Github PK
View Code? Open in Web Editor NEWName says it all.
License: MIT License
Name says it all.
License: MIT License
I was wanting to take ember-localstorage-adapter for a spin. I found it when I queried bower repo. I updated my projects bower.json file to the following but bower wasn't able to resolve the version.
When I set my dependency to:
"ember-localstorage-adapter": "0.3.0"
I received:
Is there a particular version within the bower repo? I figured it would be 0.3.0 but I guess its not?
Visualjeff
PS. Ryan I saw you live in portland and your presentation was impressive.
When trying to fetch a relation before having .find it, it's not in the Ember store so it's not managed and not linked to his child parent. There is something missing. But what ? I could contribute, but I need some track...
A user can send a request that can have many tags. A tag can have many requests.
A company registers a tag and based on tags it registered, it gets its request. So:
var Tag = DS.Model.extend({
//other data
requests: DS.hasMany('request',{async: true}),
companies: DS.hasMany('company', {async: true})
});
var Company = DS.Model.extend({
//other data
tags: DS.hasMany('tag', {async: true})
});
var Request = DS.Model.extend({
//other data
tags: DS.hasMany('tag', {async: true})
});
And since it is async true (I know Kurko wrote not to use async true but I also read somewhere he told someone to use it), I register a tag to a company like this:
//first checks if the tag exists or not, if yes gets that tag, otherwise it creates a new one
....
company.get('tags').pushObject(tag);
company.save();
tag.get('companies').then(function(companies){
companies.pushObject(company);
tag.save();
});
....
Because of async true I have to use 'then', as get('companies') is a promise
The code above does what it should - but the problem is that after the tag is saved, its requests become an empty array.
Similarly, If I add tags to a Request, the Tag's companies becomes an empty array.
I am working on a custom adapter were the storage is a plain file, and to start with, I have borrowed some code from this adapter, which apparently is based on the indexed-db adapter. So far things work nice if i have simple relationships, lets say root item which has a has-many relationship and its child-items do NOT have its own has-many relationship. If they do have, things don't work anymore, as soon as I try to load those sub-items. I am gonna investigate what exactly will happen and report a solution if I find one. On the other, if you are aware of this issues, let me know how you think it can be solved
According to the docs (http://emberjs.com/guides/models/finding-records/) I can provide a plain object / hash as 2nd parameter to find (which will then defer to findQuery) in order to query for certain records. When I do this everything goes horribly wrong.
Somewhere along the ride the "store" is not defined.
Error & Stacktrace:
TypeError: Cannot read property 'dematerializeRecord' of null
at http://dev1.loc/eric/lvo/dist/assets/vendor.js:84238:16
at initializePromise (http://dev1.loc/eric/lvo/dist/assets/vendor.js:57898:9)
at new Promise (http://dev1.loc/eric/lvo/dist/assets/vendor.js:59494:9)
at DS.LSAdapter.DS.Adapter.extend.find (http://dev1.loc/eric/lvo/dist/assets/vendor.js:84234:14)
at http://dev1.loc/eric/lvo/dist/assets/vendor.js:84480:33
at Array.forEach (native)
at http://dev1.loc/eric/lvo/dist/assets/vendor.js:84452:23
at initializePromise (http://dev1.loc/eric/lvo/dist/assets/vendor.js:57898:9)
at new Promise (http://dev1.loc/eric/lvo/dist/assets/vendor.js:59494:9)
at DS.LSAdapter.DS.Adapter.extend.loadRelationships (http://dev1.loc/eric/lvo/dist/assets/vendor.js:84442:14) vendor.js:26496
logToConsole vendor.js:26496
RSVP.onerrorDefault vendor.js:39948
exports.default.trigger vendor.js:58511
Promise._onerror vendor.js:59510
publishRejection vendor.js:57773
(anonymous function) vendor.js:41102
DeferredActionQueues.invoke vendor.js:12667
DeferredActionQueues.flush vendor.js:12717
Backburner.end vendor.js:12180
Backburner.run vendor.js:12235
apply vendor.js:30414
run vendor.js:29032
runInitialize vendor.js:14472
fire vendor.js:3168
self.fireWith vendor.js:3280
jQuery.extend.ready vendor.js:3486
completed
Using:
"name": "ember-data","version": "1.0.0-beta.9"
"name": "ember-localstorage-adapter", "version": "0.3.2",
Works fine in version 0.3.1. I found the problem in Version > 0.3.1.
store.find('person', { name: "Peter" }).then(function(results){
// goes not here if empty result
});
store.find('person').then(function(results){
// goes here if empty result
});
here is a demo: http://jsbin.com/ciheloqisena/5/edit?html,js,console,output
I was trying to load data via JSON with embedded relations:
App.store.adapter.load(App.store, App.Front, {
"id": "1",
"posts": [{"title": "Hello World"}]
});
Unfortunately, I was getting following error:
Error: assertion failed: Unable to resolve type undefined. You may need to configure your serializer aliases.
Providing "type": "post"
and configuring an alias via App.store.adapter.configure("App.Post", { alias: "post" });
didn't help either.
I assume that because LSAdapter
's serializer extends DS.JSONSerializer
I'm able to load data via JSON (including relationships) - am I wrong?
Opening ./test/index.html
in Chrome, crashes Chrome; the "Aw, Snap!" page is shown.
Chrome User-Agent string is Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.71 Safari/537.36
.
Comment out the test for 'QUOTA_EXCEEDED_ERR when storage is full'.
would be nice to update to the new structure.
https://github.com/search?q=deprecated+ember-addon-main+definition&type=Code&utf8=%E2%9C%93
This adapter worked for me through Ember 1.7, but when I tried Ember 1.8, it breaks and I get Uncaught TypeError: undefined is not a function
on ember.js:17100 which is this line here for me:
var isPathCache = new Cache(1000, function(key) { return key.indexOf('.') !== -1; });
I had an issue today with relations not persisting over a reload using the localStorageAdapter.
Loading fixtures from an action:
Driver.IndexController = Ember.ObjectController.extend({
actions: {
/**
* An action to load fixtures, delete old ones from localStorage
* @return {[type]}
*/
loadFixtures: function() {
this.store.push('Delivery', Driver.Delivery.FIXTURES[0]).save();
this.store.push('Location', Driver.Location.FIXTURES[0]).save();
this.store.push('Location', Driver.Location.FIXTURES[1]).save();
this.store.push('Location', Driver.Location.FIXTURES[2]).save();
this.store.push('Location', Driver.Location.FIXTURES[3]).save();
this.store.push('Location', Driver.Location.FIXTURES[4]).save();
},
}
});
Models and fixtures
Driver.Location = DS.Model.extend({
address: DS.attr('string'),
delivery: DS.belongsTo('delivery', {async: true}),
});
Driver.Location.FIXTURES = [
{ id: 1, address: 'Lindvägen 3B', delivery: 1},
{ id: 2, address: 'Länsmansvägen 115', delivery: 1},
{ id: 3, address: 'Lindvägen 25', delivery: 1},
{ id: 4, address: 'Länsmansvägen 209', delivery: 1},
{ id: 5, address: 'Fjärdingsmansvägen 248', delivery: 1}
];
Driver.Delivery = DS.Model.extend({
company: DS.attr('string'),
locations: DS.hasMany('location', {async: true}),
});
Driver.Delivery.FIXTURES = [
{
id: 1,
company: 'Delivery and Logisticts Ltd',
locations: [1,2,3,4,5],
}
];
Temporary fix:
DS.JSONSerializer.reopen({
serializeHasMany : function(record, json, relationship) {
var key = relationship.key;
var relationshipType = record.constructor.determineRelationshipType(
record.constructor, relationship);
if (relationshipType === 'manyToNone'
|| relationshipType === 'manyToMany'
|| relationshipType === 'manyToOne') {
json[key] = Ember.get(record, key).mapBy('id');
// TODO support for polymorphic manyToNone and manyToMany
// relationships
}
}
});
I saw on your todo:
- Make the repo nicer to work with long-term (do something more intelligent with dependencies found in
vendor
, etc.)
Just a tip of what I currently do with my client projects
#!/bin/sh
VENDOR_FOLDER="vendor"
echo "\n == UPDATING LIBS =="
echo "\n -- updating signals.js --\n"
curl https://raw.github.com/millermedeiros/js-signals/master/dist/signals.js > $VENDOR_FOLDER/signals.js
echo "\n -- updating jquery.js --\n"
curl http://code.jquery.com/jquery.js > $VENDOR_FOLDER/jquery.js
echo "\n == FINISHED UPDATE == \n"
I save it as update.sh
so I can run sh update.sh
any time I need to update the 3rd party libs.
A more complex example and reasoning behind: https://gist.github.com/3859714
Cheers.
Last commit was 5 months ago, does it still under development ?
Cheers
If I store JS Date object, local storage just store '{ }'. Is there any solution to store Date object?
I have define one to many relationship between company and person.The records are successfully added and saved.However on reload the hasMany arrays content gets wiped out and hence all the relations get lost.
I am using ember-data-beta-1 and ember-data local storage adapter.
And my code is:
App = Ember.Application.create({});
App.Store = DS.Store.extend({
adapter: DS.LSAdapter
});
App.Company = DS.Model.extend({
name: DS.attr('string'),
turnover: DS.attr('string'),
employees:DS.hasMany('person')
});
App.Person = DS.Model.extend({
name: DS.attr('string'),
department: DS.attr('string'),
company:DS.belongsTo('company')
});
App.ApplicationRoute = Ember.Route.extend({
model: function() {
return this.store.find('company');
}
});
App.ApplicationController=Ember.ArrayController.extend({
add:function(){
this.store.createRecord('company',{
name:'xyz',
turnover:'abc'
}).save();
},
addperson:function(model){
var a=model.get('employees');
a.createRecord({
name:'pqr',
department:'lmn',
company:model
}).save();
}
});
and my index.html file is:
<title>json method#1</title><script type="text/x-handlebars">
<div id="notes" class="azureBlueBackground azureBlueBorderThin">
<button class="btn btn-default btn-xs" {{action "add"}}>New Company</button>
<div class="list-group" style="margin-top: 10px;">
{{#each controller}}
<button class="btn btn-default btn-xs" {{action "addperson" this}}>employee</button>
<h1> {{name}} {{turnover}}</h1>
{{#each employees}}
{{name}} {{department}}
{{/each}}
{{/each}}
</div>
</div>
</script>
When i have a relation where the attribute name differ from the model name i get an error.
Because the extractSingle isn't working properly. When i remove the extractSingle method from the LSSerializer, it works.
Why has the LSSerializer his own extractSingle,? When i remove it it works.
Models:
Actions:
When you add some items to the list, they get added correctly and if you reload the page, the list and the items are loaded correctly.
BUT if you then add more items to the list and reload the page again, all relations are lost! The items remain in the store, but in the list the items property is gone.
Demo page: http://jsbin.com/oKuPev/72
To reproduce:
This may not be an issue - it may just be my lack of experience with ember.
I'm having a hard time implementing the adapter and haven't found many examples showing clearly how it's done, especially in the case where the adapter is just to be used to service one model - and not the entire app. Ember docs say that in this instance one should do the following:
App.MymodelAdapter = DS.LSAdapter.extend();
But it doesn't save anything in localStorage when I call .save() - localStorage in Chrome's inspector stays stubbornly empty.
How can I debug this? A good clear example of how this could be implemented would really help.
Many thanks.
Given two models bound by a many to many relationship:
window.App.Post = DS.Model.extend({
name: DS.attr(),
content: DS.attr(),
tags: DS.hasMany('tag', {async:true})
});
window.App.Tag = DS.Model.extend({
name: DS.attr(),
posts: DS.hasMany('post', {async:true})
});
And given I have 1 tag object persisted into local storage (with its id being 1). When I do the following:
var tag = this.store.find('tag', 1)
var post = this.store.createRecord('post')
post.get('tags').addObject(tag)
post.save()
I would expect to have the tag "posts" array populated, which is not. I'm not even sure this is a bug, maybe I have to manually set the post into my tag:
tag.get('posts').addObject(post)
Thanks for your help
I have been torturing myself for 2 days to create a simple 1:n (hasMany) relationship, but it is not persisting, no matter what I do. I can add a new User, and add a new Request (a user can have many requests, a request belongs to a user).
Now, when I look at the localstorage json in the browser, I see that the requests list is not even showing up for any of the user. If I remove the user: belongsTo('user') from the Request model, the requests list in the user objects in the localstorage do appear.
Is that how it is supposed to be? In the resources/localstorage, a parent object will not keep a list of child objects in a hasMany/belongsTo relationship?
all that happens when I do not export the LSSerializer with
export default DS.LSSerializer.extend({});
If I do include the LSSerializer, I get a problem after trying to add a new request:
Uncaught TypeError: Cannot read property 'determineRelationshipType' of undefined, as it appears DS.RelationshipChange is not defined...
DS.LSSerializer = DS.JSONSerializer.extend({
serializeHasMany: function(record, json, relationship) {
var key = relationship.key;
var payloadKey = this.keyForRelationship ? this.keyForRelationship(key, "hasMany") : key;
var relationshipType = DS.RelationshipChange.determineRelationshipType(record.constructor, relationship);
if (relationshipType === 'manyToNone' ||
relationshipType === 'manyToMany' ||
relationshipType === 'manyToOne') {
json[payloadKey] = record.get(key).mapBy('id');
// TODO support for polymorphic manyToNone and manyToMany relationships
}
},
Any ideas what I got wrong?
ember data v1.0.0-beta.9
ember v 1.8.0-beta.1
LSAdapter "version": "0.4.0",
on deleting a record from hasMany relationship array ,the records get deleted However it is not persisted (saved) on localstorage.As,as a result on reload,view is rendered with deleted record also.
I am using ember-data-beta-6 and latest version of local storage adapter.
Here is snippet of code:
App.EmployeesController=Ember.ArrayController.extend({
delete:function(record){
var a=this.get('model');
a.removeObject(record);
a.save();
}
});
My model is hasMany relationship array and record is the object to be removed from that array.
I'm using Ember Data 1.0beta7. ELA is 2af84de (current master as of writing). I'm using EAK and the transpiler if that matters at all.
I've noticed that extractSingle()
seems to use the field name to guess what the type of the relation is. However, in ED, the type of the relation is intended specified to the hasMany()
helper itself, not inferred from the field name (afaict). This supports the case of having multiple relations of the same type, for instance.
The error manifests as "No model was found for $fieldname".
Right now if your record hasn't been commited its relationships have no id to associate with.
var recipe = App.Recipe.createRecord({name: 'toast'});
App.Ingredient.createRecord({name: 'bread', recipe: recipe});
App.store.commit();
// null values in the underlying data for the ids (you can see it in localStorage
Instead you have to:
var recipe = App.Recipe.createRecord({name: 'toast'});
recipe.on('didCreate', function() {
App.Ingredient.createRecord({name: 'bread', recipe: recipe});
App.store.commit();
});
App.store.commit();
I already have a hack solution in an app I'm working on, need to formalize it in this repo though.
I am still an Ember.js noob, so I'm not sure what needs to be done to make the Emberjs.com ToDoMVC application work with Internet Explorer 10. It took me numerous tries to finally make the program work with Chrome and Firefox after following each step in the Getting Started section on the Ember.js site. I built and rebuilt the ToDoMVC code from scratch at least three different times and spent a long time debugging. The app continues to work fine now with Firefox and Google Chrome. But it still doesn't work with Internet Explorer 10. Haven't tried an earlier version of IE yet.
Maybe somebody has a clue about what I am missing or overlooking or ???
Thanks.
--------------------------
DEBUG: Ember.VERSION : 1.0.0-rc.3
DEBUG: Handlebars.VERSION : 1.0.0-rc.3
DEBUG: jQuery.VERSION : 1.9.1
DEBUG: -------------------------------
SCRIPT5007: Unable to get property 'getItem' of undefined or null reference
local_storage_adapter.js, line 166 character 5
-------
*** local_storage_adapter.js Line 166 is the shown below, under _loadData:
// private
_getNamespace: function() {
return this.namespace || 'DS.LSAdapter';
},
_loadData: function() {
var storage = localStorage.getItem(this._getNamespace());
this._data = storage ? JSON.parse(storage) : {};
},
etc. ***
I installed as instructed: bower install --save-dev ember-localstorage-adapter
and have this in adapters/application.js:
import DS from 'ember-data';
export default DS.LSAdapter.extend({
namespace: 'todoapp'
});
Wouldn't I also need to import the localstorage adapter somehow? I tried to import it from the bower directory but still no luck
This is the error I have:
Error while processing route: todos.index Cannot read property 'extend' of undefined TypeError: Cannot read property 'extend' of undefined
I have one model in my application that uses the LS Adapter and another than uses fixtures as the data right now is hard coded but eventually we'll pull from a REST endpoint. I can successfully attach the data using a hasMany relationship from the LS to fixtures but if I reload the page it seems the LS adapter validates the data before the fixture adapter has time to load the fixtures. Is there a way around this?
I am having the following error when I try to load a Model with a hasMany relationship:
Assertion failed: You looked up the 'items' relationship on 'App.List:ember236:1' but some
of the associated records were not loaded. Either make sure they are all loaded
together with the parent record, or specify that the relationship is async (DS.attr({ async: true })
)
Demo page: http://jsbin.com/oKuPev/49
Versions:
Ember v1.0.0
Ember Data v1.0.0-beta.1-140-ga51f29c
and latest localstorage adapter.
i'm useing ember-cli 0.046 and after npm install --save-dev ember-localstorage-adapter
i can not use ember g adapter application
or ember server
, it reports:
23:42 $ ember s
version: 0.0.46
Cannot read property 'pkg' of null
TypeError: Cannot read property 'pkg' of null
at Function.Addon.resolvePath (/home/ming/work/chat/node_modules/ember-cli/lib/models/addon.js:283:18)
at Function.Addon.lookup (/home/ming/work/chat/node_modules/ember-cli/lib/models/addon.js:298:22)
at /home/ming/work/chat/node_modules/ember-cli/lib/models/project.js:180:34
at visit (/home/ming/work/chat/node_modules/ember-cli/lib/utilities/DAG.js:23:3)
at visit (/home/ming/work/chat/node_modules/ember-cli/lib/utilities/DAG.js:21:5)
at DAG.topsort (/home/ming/work/chat/node_modules/ember-cli/lib/utilities/DAG.js:82:7)
at Project.initializeAddons (/home/ming/work/chat/node_modules/ember-cli/lib/models/project.js:178:9)
at Project.eachAddonCommand (/home/ming/work/chat/node_modules/ember-cli/lib/models/project.js:205:10)
at module.exports (/home/ming/work/chat/node_modules/ember-cli/lib/cli/lookup-command.js:52:13)
at CLI.<anonymous> (/home/ming/work/chat/node_modules/ember-cli/lib/cli/cli.js:31:26)
below is my ember version,
DEBUG: ------------------------------- vendor.js:28037
DEBUG: Ember : 1.7.0 vendor.js:28037
DEBUG: Ember Data : 1.0.0-beta.10 vendor.js:28037
DEBUG: Handlebars : 1.3.0 vendor.js:28037
DEBUG: jQuery : 1.11.1 vendor.js:28037
DEBUG: -------------------------------
anyone can do me a favor? thanks
i have some problem when trying to update a record .i ask the question in stackoverflow. but i think the problem is LSA dosent work correctly with ember data 1.0.0 so when LSA support ember data 1.0.0
thanks
I'm working on an example blogging app (https://github.com/michaelrkn/blogger/tree/86b134b05d9749136b76202841769c2c6808ec99) for an Ember class I'm teaching. I'm using the LS adapter.
In my models, a post has many comments. As instructed in the LS adapter README, I have not used {async: true}
(at least at the point at which the linked commit was made).
I can create a post, and write some comments on it. However, if I refresh the page, and then click on a post, I get the error "You looked up the 'comments' relationship on 'Blogger.Post:ember477:00hdt' but some of the associated records were not loaded." If I load the page at the URL for that particular post (eg file:///Users/michael/Code/blogger/index.html#/00hdt), that particular route won't throw an error, but browsing to any other post will.
If I add {async: true}
, the app does not throw those errors.
modelNamespace: function(type) {
return type.url || type.toString();
}
Maybe i got it wrong but type.toString() will always return: (subclass of DS.Model)
.
Changing type
to type.typeKey
should fix it. Should I submit a PR?
All tests fail on Travis due to misconfiguration.
$ phantomjs test/phantomjs-index.js
Can't open 'test/phantomjs-index.js'
The Ember.copy should be changed in a deepcopy. Otherwise is it possible ember-data changes the serialized id back to a complete Model.
When this problem occurs, your hasMany relations break at the second record you create
probably use userData or something, if you search "localStorage polyfill" you'll find some good stuff.
I'm using the latest copy of the adapter. I have a controller that looks like this:
Blogger.NewPostController = Ember.Controller.extend({
actions: {
save: function() {
var newPost = this.store.createRecord('post', {
title: this.get('title'),
body: this.get('body')
});
newPost.save();
this.transitionToRoute('posts');
}
}
});
Post model:
Blogger.Post = DS.Model.extend({
title: DS.attr(),
body: DS.attr(),
comments: DS.hasMany('comment')
});
Comment model:
Blogger.Comment = DS.Model.extend({
text: DS.attr(),
post: DS.belongsTo('post')
});
When the save
action is triggered, newPost.save();
throws Uncaught ReferenceError: get is not defined localstorage-adapter-0.3.2.js:16.
You can see the app live at http://ember-blogger.site44.com/#/new-post; just click Save to trigger the exception.
Emberfront.LoginController = Ember.Controller.extend({
actions: {
login: function() {
var _self = this;
var formData = {user: {name: this.get('name'), password: this.get('password')}};
Ember.$.ajax({
type: "POST",
url: "http://localhost:3000/log_in",
dataType: "json",
data: formData,
success: function(json){
var signIn = _self.store.createRecord('signIn', {id: 1, token: json.token});
}
});
this.store.find('signIn', 1).then(function(data) { console.log(data.get('token')) });
}
}
});
Emberfront.PostsController = Ember.ObjectController.extend({
actions: {
log: function(){
this.store.find('signIn', 1).then(function(data) { console.log(data.get('token')) });
}
}
});
Here's an img of console after hitting the login_controllers login action
Just to show that the record is actually being saved to localstorage
App.model.createRecord({id: 'singleton'}).save();
App.model.createRecord({id: 'singleton'}).save();
App = Ember.Application.create();
App.Router.map(function() {
});
App.ApplicationAdapter = DS.LSAdapter.extend({
namespace: 'ember-relations'
});
App.Post = DS.Model.extend({
title: DS.attr(),
tags: DS.hasMany('tag')
});
App.Tag = DS.Model.extend({
title: DS.attr(),
posts: DS.hasMany('post')
});
var FIXTURES = {
'App.Post': {
records: {
'11': { id: '11', title: 'A post about HTML5', tags: [ '11' ] },
'12': { id: '12', title: 'Some post about JavaScript and HTML5', tags: [ '11', '12' ] }
}
},
'App.Tag': {
records: {
'11': { id: '11', title: 'HTML5', posts: [ '11', '12' ] },
'12': { id: '12', title: 'JavaScript', posts: [ '12' ] }
}
}
};
localStorage.setItem('ember-relations', JSON.stringify(FIXTURES))
App.IndexRoute = Ember.Route.extend({
model: function() {
return this.store.find('post');
}
});
<h2>Posts:</h2>
<ul>
{{#each}}
<li>
{{title}}
<ul>
<h3>Tags:</h3>
{{#each tags}}
<li>{{title}}</li>
{{else}}
<li>No tags associated with this post.</li>
{{/each}}
</ul>
</li>
{{else}}
<li>No posts found.</li>
{{/each}}
</ul>
The code results in the following exception: Assertion failed: You looked up the 'tags' relationship on '<App.Post:ember276:11>' but some of the associated records were not loaded. Either make sure they are all loaded together with the parent record, or specify that the relationship is async (DS.hasMany({ async: true }))
I'm using:
Ember 1.2.0
Ember Data 1.0.0-beta3
Handlebars 1.1.2
jQuery 1.10.2
I have code that tries to set the owner of a model instance by simply setting the id of the owner as follows:
tableJSON = {id: 1, room_id: 1}
rec = App.Table.createRecord();
rec.setProperties(tableJSON);
App.store.commit();
It does not set the room on the table model. The model specifies that table belongs to room.
when I call table.get('room'), it returns null.
What the title says. This is a problem when the record contains a date attribute as it is transformed from a string to a date object and then from a date object to null.
Commenting out the following line appears to fix this:
var extracted = serializer.extractSingle(store, type, record);
Hi All,
Interesting situation I'm facing and hope that you all could help. I have an order
model in my application with many properties that I'd like to persist like Name, Address, Shipping, etc. in case a user closes their browser in the middle of checkout.
However, as part of my order
model I also have properties for Credit Card data that, for security reasons, should not be stored:
export default DS.Model.extend({
...
paymentCardName: DS.attr('string'),
paymentCardNumber: DS.attr('string'),
paymentCardExpMonth: DS.attr('number'),
paymentCardExpYear: DS.attr('number'),
paymentCardCVC: DS.attr('string'),
...
});
Is there a way to exclude these properties from being saved when I call order.save()
in my code to prevent these from being persisted? I'd rather not mess with the structure of the models at this point as it will involve much rework in the code. However, I can see if there's no better option the need to separate out the payment data into it's own model.
Thanks in advance
When I change the App adapter from Fixture to LS adapter. I found that the loading event will not get triggered correctly.
I post the code on SC.
http://stackoverflow.com/questions/25841918/why-does-not-lsadapter-trigger-the-loading-event-in-ember-js
Bower depends on a tagged release being cut for resolution. The latest is 0.2.0.
https://github.com/rpflorence/ember-localstorage-adapter/releases
Fixes #54
The adapter does not appear to be storing the item keys in the list of a polymorphic hasMany association as hashes containing the item type. Apparently this is a requirement for polymorphic associations to work.
It's possible that I've missed something obvious. I am being a bit naughty and using 1.0.0beta7 instead of the stated requirement of beta6 of ED.
Currently, it fails like Ember Data bug #1622 (in which someone needed to ensure that their REST adapter was returning the correct ID list format).
I believe it should transition to Error?
I have localstorage adapter set as a second adapter in an Ember application like so:
MyApp.SearchResult = DS.Model.extend({
name: DS.attr('string')
});
MyApp.SearchResult.reopen({
url: '/myApp/searchResult'
});
MyApp.store2 = DS.Store.create({
revision: 12,
adapter: DS.LSAdapter
});
I can "create" a record:
MyApp.store2.createRecord(MyApp.SearchResult, {
name: 'foo',
});
But I can't commit them. When I refresh the page the records are gone. MyApp.store2 also doesn't have .commit() method. Am I missing something in the configuration?
Can you git tag the 0.1.0 version so it's installable by bower? right now bower installs master.
Hello.
We are using the LSAdapter for some of our models.
The flow is as following:
The issue that we want to solve is changes in the model that were done after the local storage was populated.
Scenario:
What we want is that on refresh the local storage will become invalid: it will be cleaned up, the new JSON will be pulled from the server and the model will be reloaded.
We can not just clean the local storage, this way the app will crash.
Will appreciate your help.
Thanks a lot.
Victor.
materializeAttribute: function(record, serialized, attributeName, attributeType) {
var value = this.extractAttribute(record.constructor, serialized, attributeName);
....
In the materializeAttribute method above I'm getting the exception below because extractAttribute seems to be undefined. Have you had anyone else upgrade w/ success?
**
undefined' is not a function (evaluating 'this.extractAttribute(record.constructor, ...
This seems to happen as I go to find an entity
var rating = store.find(CodeCamp.Rating, 1);
bower.json
claims subj to be v0.3.1, but latest git tag is v0.2.0.
Bower uses git tags to fetch versions, can you please add tags?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.