Comments (5)
I'm on extended vacation right now and may get back to looking at this in a
week. You lack .catch on your useage of promises here.
The "uncaught" is from an exception being thrown in promise handling and
there being no catch in place to handle it.
I'm fairly certain the error is in your code though and I'm not able to
help you out. If you do find a solution and it turns out to be a problem
with the lib, make a repro and submit a PR if you can.
Best of luck.
On May 5, 2015 7:07 AM, "Tom Pom" [email protected] wrote:
In my code I have a function like that:
findOneByIndex: function(entityName, id, index) {
var d = $q.defer();
var promise = d.promise;$indexedDB.openStore(entityName, function(table) { table.findWhere(table.query().$index(index).$eq(id)).then(function(result) { if (result.length === 0) { console.log('No objects found'); return d.reject(result); } else { return d.resolve(result[0]); } }, function(error) { console.log(error); }); }, 'readwrite').then(null, function(error) { console.log(error); }); return promise;
}
If I try to query IDB with an index that does not exist, I would expect
the exception gets caught and logged. The problem is when I try to test
this behaviour, I get:Uncaught NotFoundError: Failed to execute 'index' on 'IDBObjectStore': The specified index was not found.
at angular-mocks/angular-mocks.js:9I was wondering if it's a problem with angular mocks or with
angular-indexedDB.
In my test I am injecting $indexedDB—
Reply to this email directly or view it on GitHub
#30.
from angular-indexeddb.
Could you be more precise on where .catch is missing? Because from the Angular documentation
promise.catch(errorCallback)
is a shortand for
promise.then(null, errorCallback)
I tried to use the function findBy(index, id) instead of findWhere(), but the result is the same. My point is: shouldn't the error be handled inside the library, in the form of a promise being rejected?
For example, if you try to call openStore() on a non existing database, the promise is rejected and the error is handled correctly as well.
Looking at angular-indexedDB code, all the functions that take an index as a parameter do not check the integrity of it and they concatenate other functions call assuming the index is correct.
from angular-indexeddb.
Okay I've looked at the code a bit more in depth and I can try to submit a pr in the next days.
It's just about checking if the index provided by the user is inside IDBObjectStore.indexNames, and it addresses the functions findBy() and eachWhere().
from angular-indexeddb.
Feel free.
from angular-indexeddb.
Oh well, I tried and failed.
The core problem was that i was trying to put two transactions inside one function, and it was always complaining about "$digest being already in progress" or something like that
from angular-indexeddb.
Related Issues (20)
- Adds then retrieves first time. Can't retrieve second time HOT 3
- not able to get error log HOT 2
- Upgrade function ordering HOT 1
- logs in code HOT 3
- Wrong usage of @defer.reject() HOT 6
- Unnecessary runtime bower dependency HOT 1
- Is querying over multi entry indexes implemented? HOT 4
- Extremely slow calling table.getAll() in IE (11) HOT 9
- t text to bianry HOT 1
- Unable to install HOT 2
- Additional Maintainers Needed
- Not able to use $indexedDB, $indexedDBProvider in angular service HOT 1
- How can i check if a data sore is exist to insert in it and if isn't create new one?
- i need a function to call it for creating new data store? HOT 1
- How can i get existing data store names...Please? HOT 1
- Unable to store an array of objects corresponding to one key HOT 1
- A) READ THIS BEFORE YOU CREATE AN ISSUE
- Detect failure at the time of opening the store HOT 4
- getAll with limits HOT 2
- Difference between .getAll() and .each()? HOT 6
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 angular-indexeddb.