Git Product home page Git Product logo

idbwrapper's People

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

Watchers

 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

idbwrapper's Issues

Support cordova android ?

Hi.
Do someone try to use library for cordova android application ?
In mobile and desctop browsers all right. But IDBWrapper doesn't work for my android 4.1.2.
Is it possible use library for cordova ?
Thanks.

Chrome 21 : Impossible to use IDBWrapper

Hi there,

4 days ago, I got interested in IndexedDB and I came to use IDBWrapper for some tests (and also because it's a remarkable work)

Since then, Chrome 21 was released, and now, IDBWrapper doesn't seem to be working anymore (you have to delete manually your local databases to see it not working). I get this error :

Uncaught Error: InvalidStateError: DOM IDBDatabase Exception 11

When I check IndexedDB databases, i get this :

Security origin:http://jensarps.github.com
Name:appdb
Version:

It seems Chrome finally adopted some of the new "standards" (read this here https://groups.google.com/a/chromium.org/d/topic/chromium-html5/8C-NWF2FajA/discussion ) about the setVersion or onupgradeneeded methods

Do you know what needs to be corrected ?

Thanks again for your work !

Examples do not work in Firefox

I am unable to use the examples in Firefox 10, OSX. Works fine in Chrome.

[11:43:07.579] uncaught exception: [Exception... "This error occurred because an operation was not allowed on an object. A retry of the same operation would fail unless the cause of the error is corrected."  code: "2" nsresult: "0x80660002 (NS_ERROR_DOM_INDEXEDDB_NON_TRANSIENT_ERR)"  location: "http://jensarps.github.com/IDBWrapper/IDBStore.js Line: 60"]

makeKeyRange with boolean

Hi and thank you for your wrapper :D

I am building a mobile app where I am querying the local database.

I made fake range as lower and upper value are the same, and it works fine for object properties that are integer and strings but fails on boolean.

Error: DataError: DOM IDBDatabase Exception 0
Error: The data provided does not meet requirements.
at Object.IDBStore.makeKeyRange (http://myip/src/assets/libs/IDBWrapper-master/idbstore.js:949:36).

I have no idea how to solve it, I looked over Internet and found no example using query on boolean property, maybe you could provide a basic one. :)

Thanks

localStore failover for safari

it would be nice to build a basic localStorage failover for non IndexedDB browsers that allows for basic index creation and querying by filtering the results.

var customers = new IDBStore({
dbVersion: 1,
storeName: 'customer',
keyPath: 'id',
autoIncrement: true,
onStoreReady: function(){
console.log('Store ready!');
}
});

var customers = localSorage['customer'][1] = {keyPath:'id',indexes:[{name:'firstname'},records:{}]};

question about keyPaths on transaction objectStores

Hiya, I'm trying to figure out why I'm getting a DataError when writing this data to .batch:

[
  { type: 'put', key: 'foobatch1', value: 'bar1' },
  { type: 'put', key: 'foobatch2', value: 'bar2' },
  { type: 'put', key: 'foobatch3', value: 'bar3' }
]

One thing I noticed is that batchTransaction.objectStore(this.storeName) inside of the .batch implementation returns an objectStore that has autoIncrement: true and keyPath: "id" (which is likely the cause of the DataError above)

For my use case I need to totally disable keyPath and autoIncrement, so I"m using these options when initializing the IDBStore:

{
    autoIncrement: false,
    keyPath: ""
}

I also tried keyPath: false and keyPath: null but still got the same errors. Do you know if IndexedDB lets you control/influence the autoIncrement/keyPath on transaction objectStores? If not, do you have any suggestions on how I can write the above data in a batch transaction?

Duplication in documentation

On the section that explain the members of the object provided to the IDBStore constructor, the line about indexes appears two time

support null values

Null values can be successfully inserted via put().
However, in get(), there is no difference between a missing key and one with value null.

Do you think it is feasible to add an API to differentiate, or better add a second parameter to the get onSuccess callback to differentiate in this particular case?

This is needed to support the latest leveldown interface Level/level-js#41

Doesn't appear to work anymore

I went to the examples site and it failed to save any information. Errors appear in the chrome console log concerning the native API. I'm on Chrome 49 desktop.

query or iterate can't support multiple index

when we use the iterate ,we always need two indexes, but from the implementation,we can't do it, expect to support this new feature,thanks!

current API:
customers.iterate(onItem, {
index: 'lastname',
keyRange: IDBKeyRange,
order: 'ASC',
filterDuplicates: false,
writeAccess: false,
onEnd: onEndCallback,
onError: onErrorCallback
});

new API expect:

customers.iterate(onItem, {
[{
index: 'lastname',
keyRange: IDBKeyRange,
order: 'ASC'},
{
index: 'date',
keyRange: IDBKeyRange,
order: 'ASC'
}
],
filterDuplicates: false,
writeAccess: false,
onEnd: onEndCallback,
onError: onErrorCallback
});

can we do that ?

Firefox DataError

On latest firefox I get a 'DataError: Data provided to an operation does not meet requirements'.

var options = {
        dbVersion: 1,
        storePrefix   : myprefix-',
        storeName: 'settings',
        keyPath: 'id',
        autoIncrement : true,
        onStoreReady  : storeReadyFunc
};
idbs_settings = new IDBStore(options);

Later on I try a batch insert:

function saveSettings(options){
    var operations = [];
    for (var prop in options) {
        if (options.hasOwnProperty(prop)){
            var obj = {
                id: parseInt(prop),
                value: options[prop]
            };
            operations.push({
                type  : "put",
                value : obj
            });
        }
    }
    idbs_settings.batch(operations,function(result){
        _logger.log(result);
    });
}

This works on Chrome and IE10, still not tested on Safari.

Doesn't work in Safari (Private Window) and in iframe on iOS

Hello,

I have the issue with IDBWrapper functionality in Safari (Private Window) and in the iframe on iOS.
Error message: "TypeError: null is not an object (evaluating 'a')".
In another browsers and devices, everything works well.

I have used 1.6.0 version. In the latest version (1.7.1) I have the same issue.

How can I solve this issue? Do you have any suggestions?
Please check the simple code example below:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Test</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/idbwrapper/1.6.0/idbstore.min.js"></script>
    <script src="script.js"></script>
</head>
<body>
    <h1>Test</h1>
</body>
</html>
var customers = new IDBStore({
  dbVersion: 1,
  storeName: 'customer',
  keyPath: 'id',
  autoIncrement: true,
  onStoreReady: function(){
    console.log('Store ready!');
  }
});

You can check it on this page: https://gist.github.com/jensarps/1391434#file-index-html

Thanks!

to add an ability to use deferred objects

Here is usage example:

var dude = {
  firstname: 'John',
  lastname: 'Doe',
  age: 52,
  emails: [
    '[email protected]',
    '[email protected]'
  ]
};

var onsuccess = function(id){
  console.log('Yeah, dude inserted! insertId is: ' + id);
}
var onerror = function(error){
  console.log('Oh noes, sth went wrong!', error);
}

customers.put(dude).done(onsuccess).fail(onerror)
$.when(customers.put(dude), customers.put(dude), customers.put(dude)).done(function() {alert('awesome');});

IE always asks to bump dbVersion again

We're experiencing the following in Internet Explorer 11 on Windows 8.1. We're creating an IDBStore with the following config:

var IdbWrapper = require("idb-wrapper"); // we're using npm and browserify

new IdbWrapper({
  "storePrefix": "XX-",
  "dbVersion": 2,
  "indexes": [{"name":"user.id","keyPath":"user.id","unique":false,"multiEntry":true}],
  "keyPath":"activityId",
  "storeName":"activities"
});

We bumped the dbVersion to 2, because this is the first time we're changing the schema by adding an index to this database. In Internet Explorer now the following happens: We clear all IndexedDB files through the Settings, then refresh the application in the browser, click through functionality that uses this database, everything is fine. Then we refresh the application again, and this time, when the IDBStore is initialised, we get the following error:

ERROR initializing idbWrapper
Cannot modify index "user.id" for current version. Please bump version number to 3."

If we then bump the version to 3, the same thing happens again, after second refresh it asks us to bump to 4, etc.

Any idea why this might be happening?

Thanks a lot.

thinner npm version

Hi,

Would it be possible to publish this module to npm without the closure compiler jar and the examples?
I tried looking around but didn't see where closure is used.. maybe I missed it.

Thanks

Yaniv

Offset and limit options?

Hi,

Is there a way to set a limit/offset when using the query method? It seems that the only way to configure the query is makeKeyRange, but unless I am missing something it doesn't let you set a offset or limit.

Thanks

Regards

putAll method

It would be nice to have a putAll method to iterate over an array of objects and put them

IndexedDBShim Support?

I am getting this error(Error: undefined is not an object (evaluating 'this.store.query')) from https://github.com/mWater/minimongo/blob/master/dist/minimongo.js#L832

When I install https://github.com/axemclion/IndexedDBShim

I see here https://github.com/jensarps/IDBWrapper/blob/master/idbstore.js#L47 that this shim should be supported?

I am working on iOS WKWebView. It is a cordova app and all the research that I can turn up says that iOS has botched the implementation bad. But the shim claims to be able to fix it. And it does get me past the original error from within minimongo which was db = undefined.

indexeddbshim/IndexedDBShim#244

So I originally created an issue in the shim repo thinking that installing it broke something with IDBStore making the query method disappear. But then I got digging deeper and saw that IDBWrapper seems to be intending to coexist with the shim as is.

Is there a specific version that works better? Or is this a real bug? Or is the assumed support not really there? Any suggestions otherwise?

errors

Don't throw or log errors.

Have a callback for errors preferably the one I pass to IDBWrapper and pass them an error there

var store = IDBWrapper(opts, function (err) {
    if (err) { /* I handle it */ }
    // store is ready
})

First time opening database in Firefox gives error

in function get (line 266 in the source file at this moment), at line:

var getTransaction = this.db.transaction([this.storeName], this.consts.READ_ONLY);

A mutation operation was attempted on a database that did not allow mutations

In Chromium (Linux) works fine, on Firefox 14.0.1, Linux, I got the error, after a Shift-F5, full reload of the page and next attempt, everything works ok. So I presume it's a bug related only to the first time opening (creating) of the database file.

Teo

Polyfill support?

Hey, I love your library.

Does it work with any of the polyfills? I want to use it on Safari.

Why database per store?

var myStore = new IDBStore({
storeName: 'Store',
storePrefix: 'IDBWrapper-',
})

Will create database IDBWrapper-Store and object store Store inside, I don't see how to have more then one store in one db, why?

'Object store couldn't be created' when opening two times the same page

Hello,

I have an issue on FF 47 (at least). When we open two times the same page using IDBWrapper,
the database seems to corrupt itself. I get this error : 'Object store couldn't be created' even after rebooting FF.

To solve the problem i must clear IDB files in firefox folders. :(

Do you have an idea of what can be the problem?

Thank you very much.

Database Rename

The only thing keeping me from using this library is line 42:

this.dbName = 'IDBWrapper-' + this.storeName;

Why are you adding a prefix (that isn't even configurable) to the store name?

Bug report : Index creation not working

Hi.

I didn't know if I should send you an email or submit an issue on GitHub, so there it is. I'm not familiar with GitHub, so tell me if I'm doing anything wrong :]

As I'm starting to play around with IDBWrapper, I tried to create an index for my objectStore (I'm using your "basic" example) :

(I'm using Chrome 21 & 22. FF is kinda lame for debugging IndexedDB right now)

function init() {
    // create a store ("table") for the customers
    customers = new IDBStore({
        dbName: 'appdb',
        storeName: 'customer',
        keyPath: 'customerid',
        autoIncrement: true,
        onStoreReady: storeIsReady
    });
    /// ... ///
}

function storeIsReady() {
    customers.createIndex('lastname', 'lastname', true);
    refreshTable();
}

I instantly get this (now infamous) error :

Uncaught Error: InvalidStateError: DOM IDBDatabase Exception 11

This error occurs in the createIndex function, when enterMutationState enters in the onSuccess event.

Line 357 (on the last commit)

var result = evt.target.result;

So after working around the file and reading this discussion (https://groups.google.com/a/chromium.org/forum/?fromgroups#!topic/chromium-html5/RQFrG9SDPTI), I modified the createIndex, setVersion and enterMutationState functions :

enterMutationState: function (onSuccess, onError, options) {
  if (this.newVersionAPI) {
    this.dbVersion++;
    var openRequest = this.idb.open(this.dbName, this.dbVersion, this.dbDescription);
    openRequest.onupgradeneeded = onSuccess;
    openRequest.onsuccess = onError;
    openRequest.onerror = onError;
    openRequest.onblocked = onError;
  } else {
    this.setVersion(onSuccess, onError, options);
  }
},

/// ... ///

setVersion: function (onSuccess, onError, options) {
  options || (options = {});
  onError || (onError = function (error) {
    console.error('Failed to set version.', error);
  });
  var versionRequest = this.db.setVersion(this.dbVersion);
  versionRequest.onerror = onError;
  versionRequest.onblocked = onError;

  versionRequest.onsuccess = function (evt) {
    if (options.waitForTransactionEnd) {
      var transaction = versionRequest.result;
      transaction.oncomplete = onSuccess;
    } else {
      onSuccess();
    }
  };
},

///...///

createIndex: function (indexName, propertyName, isUnique, onSuccess, onError) {
  onError || (onError = function (error) {
    console.error('Could not create index.', error);
  });
  onSuccess || (onSuccess = noop);
  propertyName || (propertyName = indexName);

  var options = {waitForTransactionEnd:true};
  var that = this;

  this.enterMutationState(hitch(this, function (evt) {
    var result = evt.target.db;
    var index;
    if (result.objectStore) { // transaction
      index = db.objectStore(this.storeName).createIndex(indexName, propertyName, { unique: !!isUnique });
    } else { // db
      var putTransaction = result.transaction([that.storeName] /* , this.consts.READ_WRITE */);
      var store = putTransaction.objectStore(that.storeName);
      index = store.createIndex(indexName, propertyName, { unique: !!isUnique });
    }
    onSuccess(index);
  }), onError, options);
},

So right now, everything's a little smoother, but I still get the same error, only now occuring on this line :
index = store.createIndex(indexName, propertyName, { unique: !!isUnique });

I can't inquiry further today, but I guess something goes wrong with the transaction. Maybe I took a wrong approach on this problem ?

library has error in it..

I tried this library... doesnt work.. You'll get this error right from the start..... Unable to get property 'transaction' of undefined or null reference : line 466 in IDBStore.js

ie9 polyfill?

Hi, I was wondering if there is any lib that you guys use so this tool can work on ie9?

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.