Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insert multiple documents #51

Closed
torto opened this issue Feb 6, 2014 · 9 comments
Closed

Insert multiple documents #51

torto opened this issue Feb 6, 2014 · 9 comments

Comments

@torto
Copy link

torto commented Feb 6, 2014

I'm trying to insert multiple documents but are inserting only the first document. ex:

server.person.add({JSON1}).done(function(item){
server.person.add({JSON2}).done(function(item){
alert('ok');
});
});

The return is: [{JSON1}]
Expected: [{JSON1}, {JSON2}]

is it something very wrong I'm doing? if you place the two in a json array inserts it more when I try to insert anything else he does not insert.

@aaronpowell
Copy link
Owner

You can pass multiple arguments to the .add method, it essentially takes a splat, so you can take this:

server.person.add(JSON1, JSON2).done(function (items) { alert('ok'); });

Check out this test - https://github.com/aaronpowell/db.js/blob/master/tests/specs/server-add.js#L107

@torto
Copy link
Author

torto commented Feb 6, 2014

insert two json not working on the same method, and nor insert new jsons at different times.

@aaronpowell
Copy link
Owner

Are you able to create a test case? That test passes as expected

@torto
Copy link
Author

torto commented Feb 6, 2014

I created another test case, no exception occurs but does not insert the two json.

@aaronpowell
Copy link
Owner

can you share the test case?

@torto
Copy link
Author

torto commented Feb 6, 2014

Android 4.3 - https://github.com/tortoyoyo/IndexDbTeste

folder assets / www / index.html

@torto
Copy link
Author

torto commented Feb 6, 2014

Firefox OS happens the same error

@torto
Copy link
Author

torto commented Feb 6, 2014

I found the error, I'm using the polyfill IndexedDBShim for android, the words "continue" and "delete" are reserved for the system (or not) and some internal error. To perform these words we must make these changes:

before:

cursor.continue(); //line 376
var req = store.delete(key); //line 230

after:

cursor["continue"](); //line 376
var req = store["delete"](key); //line 230

is now working :D thank you.

@aaronpowell
Copy link
Owner

That could be a bug in Firefox OS as it while they are reserved words they are also valid identifiers when using strict mode in ES5 (which db.js does).

I'll see about changing it when I get a chance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants