kurko / ember-indexeddb-adapter Goto Github PK
View Code? Open in Web Editor NEWEmber Data IndexedDB Adapter
License: MIT License
Ember Data IndexedDB Adapter
License: MIT License
For some reason, associations using this adapter are being duplicated.
cartItem = this.store.createRecord('cartItem', {
price: inventoryItem.get('price'),
});
cart.get("cartItems").pushObject(cartItem);
console.log(cart.get("cartItems.length")); // => 1
cart.save().then(function(cart) {
console.log(cart.get("cartItems.length")); // => 2, both with same ID
cartItem.save();
});
This doesn't happen with RESTAdapter
.
Steps to reproduce:
store.unloadAll
).Expected: the values would still be present in the first association
Actual: the first association is empty
I've reproduced this in a test case: humanpractice/ember-indexeddb-adapter@7baf61ae2cd5f3e6748152090e05886db41955fa. (N.b., that branch builds on PR #20 since it needs some of the same test infrastructure.)
While the README for this project indicates that you should not use async associations with it, synchronous associations also have issues (see #13).
Hi,
I'm trying to use this adapter in a project I just created with ember-cli v0.1.6.
I was able to successfully load it as a bower dependency with the following command:
$ bower install git://github.com/kurko/ember-indexeddb-adapter.git --save
My app is built and loads fine in the browser, but when I try to configure the App object to use this adapter, I need to import the module. Here's the code I've got in my app.js
file:
import Ember from 'ember';
import DS from 'ember-data';
import Resolver from 'ember/resolver';
import loadInitializers from 'ember/load-initializers';
import config from './config/environment';
import IndexedDBAdapter from 'ember-indexeddb-adapter';
Ember.MODEL_FACTORY_INJECTIONS = true;
var App = Ember.Application.extend({
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix,
Resolver: Resolver,
ApplicationStore: DS.Store.extend({
adapter: IndexedDBAdapter.extend({
databaseName: 'tecnet-webmovil',
version: 1,
migrations: function() {
@addModel('notification');
},
}),
});
loadInitializers(App, config.modulePrefix);
export default App;
However, the import that comes last, which is supposed to load this adapter library, makes the loader output this error in the console:
Could not find module ember-indexeddb-adapter
If I drop this line, then I get the following error:
Uncaught ReferenceError: IndexedDBAdapter is not defined
Any hints on how to solve this?
Hi!
findQuery with no result reject the promise with undefined.
In the same case, findMany resolve with an empty array.
I think findQuery should do the same.
If you are agree, I can create a pull request.
I am working with a few models with hasMany relationships on them and was getting the following errors when calling deleteRecord()
followed by save
on them:
Error: Assertion Failed: calling set on destroyed object
at new Error (native)
at Error.EmberError (file:///home/doug/workspace/project/js/ember-1.7.0.js:13538:23)
at Object.Ember.assert (file:///home/doug/workspace/project/js/ember-1.7.0.js:3722:15)
at set (file:///home/doug/workspace/project/js/ember-1.7.0.js:16834:13)
at Ember.Object.extend.hasManyDidChange (file:///home/doug/workspace/project/js/ember-data-beta7.prod.js:5939:11)
at null. (file:///home/doug/workspace/project/js/ember-data-beta7.prod.js:5928:18)
at file:///home/doug/workspace/project/js/ember-1.7.0.js:14897:20
at Object.OrderedSet.forEach (file:///home/doug/workspace/project/js/ember-1.7.0.js:14739:14)
at Object.Map.forEach (file:///home/doug/workspace/project/js/ember-1.7.0.js:14895:14)
at Ember.Object.extend.reloadHasManys (file:///home/doug/workspace/projectl/js/ember-data-beta7.prod.js:5925:23)
followed by:
Uncaught Error: Assertion Failed: Error: Assertion Failed: calling set on destroyed object ember-1.7.0.js:3722
Ember.assert ember-1.7.0.js:3722
RSVP.onerrorDefault ember-1.7.0.js:27916
exports.default.trigger ember-1.7.0.js:46478
Promise._onerror ember-1.7.0.js:47477
publishRejection ember-1.7.0.js:45740
(anonymous function) ember-1.7.0.js:29069
DeferredActionQueues.invoke ember-1.7.0.js:634
DeferredActionQueues.flush ember-1.7.0.js:684
Backburner.end ember-1.7.0.js:147
Backburner.run ember-1.7.0.js:202
apply ember-1.7.0.js:18380
run ember-1.7.0.js:16999
operation.onsuccess ember-indexeddb_adapter.js:894
I learned through this EmberJS discussion post how to fix it from another user's post:
My custom data adapter's delete function was returning a json object. As soon I set it to return an
empty string the issue went away.
I added return '';
on operation.onsuccess
which allows the records to be deleted, but still get the errors so its not a perfect fix. I will update this if I resolve it.
I tried loading a route without {async:true} on the hasMany relation of the route's model...but I got the "uncaught Error: Assertion Failed: You looked up the 'model' relationship on 'model'..." error. I added the {async:true} option back to the hasMany relationship and the route loaded fine. Maybe the readme needs to be updated?
When trying to install this adapter, as per the README, using bower, the following error is generated:
╰─➤ bower install ember-indexeddb-adapter --save
bower not-cached git://github.com/chlu/ember-indexeddb-adapter.git#*
bower resolve git://github.com/chlu/ember-indexeddb-adapter.git#*
bower ECMDERR Failed to execute "git ls-remote --tags --heads git://github.com/chlu/ember-indexeddb-adapter.git", exit code of #128
Additional error details:
fatal: remote error:
Repository not found.
I'm using ember-cli 0.1.12, and bower 1.3.12.
First of all, thanks for putting this project in Github, available with an open source license. It's really useful.
But it would be just a little bit more useful if you could tag every release with a Git tag so instead of cloning the latest master and build it to use it we could rely on a more reliable release tag.
I'm finding that it doesn't seem to be doing all the things it needs to do in order to be the default store.
Hi, I was running the tests with rackup
and it looks like more than a few are failing. #findQuery - overriding Adapter#findQuerySearchCriteria
is one. I think I have that fixed...
#save doesn't lose or duplicate relationships from the store
- this is a big one - getting back the 'phones' relations has the same record repeated twice...
Hey Alexandre -
Any reason we can't use typeKey rather than toString to establish modelName ?
I'm using Ember App Kit, and the toString method fails every time, seems typeKey is the new approach I see throughout Ember Data these days.
One to one relationships work perfectly but I'm having issues with the hasMany relationships.
I have a team that hasMany teamMembers. When I create the team I can view all the teamMembers by looping through them in my view. However when I refresh the page no teamMembers are shown. When I look in my indexedDB I see the team object with an array of teamMebmer ids. It's in the database but I don't think ember is reading it properly.
Here is the second scenario. A team can haveMany workspaces also. I create the workspace successfully and see it in my view when I loop through workspaces of a team.
var workspaceModel = this.store.createRecord('workspace', {
color: '95A5A6',
team: teamModel
});
The moment I call workspaceModel.save()
the workspace disappears from the view.
On both of these if I try to find()
them I get the appropriate teamMembers or workspaces
teamMembers: function() {
return this.store.find('teamMember', { team: this.get('model.id') });
}.property('model.id'),
workspaces: function() {
return this.store.find('workspace', { team: this.get('model.id') })
}.property('model.id')
I've searched around with not much luck but heard a few people say that they had to override the implementation of "serializeHasMany" in JSONSerializer to get similar problems to work. Not sure if that has anything to do with this but I wanted to throw it out there.
Hi! I’d like to use the latest version of your adapter with Bower but I can’t find it in the registry. Could you publish it officially on Bower or at least git-tag the latest version so that we can link to it? Thanks!
Looks like the bower install is pointing to wrong repository:
git://github.com/chlu/ember-indexeddb-adapter.git
instead of
git://github.com/kurko/ember-indexeddb-adapter.git
(i'm guessing thats the right repository)
I may be going about this wrong (currently on Ember App Kit and latest Ember Data)
Do we need the shim to have this adapter work out?
Thanks in advance.
I'm getting a new error that's killing all functionality after I updated to the latest ember-data beta. Looks like, maybe, the indexeddb adapter was using some private objects that are no longer present in ember-data?
DS.RelationshipChange.determineRelationshipType isn't defined anymore, specifically there is no DS.RelationshipChange object anymore.
Its specifically referenced here:
https://github.com/kurko/ember-indexeddb-adapter/blob/285d0a263d9f9d36a5de05a4addd5bda53bb29ea/packages/indexeddb-adapter/lib/indexeddb_serializer.js
I'm seriously loving this thing the more I work with it just seems like a nicer, more organized solution as compared to LocalStorage.
However I can't seem to sort out how this would work with per-model adapter and serializer definitions. It seems like you want to set a version number and ObjectStores in only one place, and the ApplicationAdapter may in some cases be something else.
Is there a recommended approach here? Or do we need to use this for all models?
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.