Giter Site home page Giter Site logo

ember-indexeddb-adapter's People

Contributors

kurko avatar mattmarcum avatar rsutphin avatar samuraisam avatar tofumatt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ember-indexeddb-adapter's Issues

hasMany records are being duplicated

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.

Data loss with async hasMany

Steps to reproduce:

  1. Define a model with at least two async hasMany associations.
  2. Create an instance with values in one of the associations and save it.
  3. Clear the store's cache (e.g., by reloading the app or by using store.unloadAll).
  4. Load the instance
  5. Set a value in the other association
  6. Save the instance
  7. Clear the store's cache again
  8. Load the instance and attempt to read values from the first association

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).

Importing as ES6 module in an ember-cli project

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?

findQuery reject if no result

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.

Assertion Failure when deleting record with hasMany relationship

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.

async:true needed to load associations

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?

Bower Install Fails

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.

Lack of tags/releases

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.

tests failing on master

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...

toString vs typeKey

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.

hasMany relationships disappear on .save() and when the page is reloaded

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.

Installing from Bower

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!

Bower Setup

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)

Problem with [email protected]

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

What to do with per-model adapters?

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.