1. 1var sqlite3 = require('..');
2. 1var assert = require('assert');
3. 1
4. 1describe('query properties', function() {
5. 1 var db;
6. 1 before(function(done) {
7. 1 db = new sqlite3.Database(':memory:');
8. 1 db.run("CREATE TABLE foo (id INT, txt TEXT)", done);
9. 1 });
10. 1
11. 1 it('should return the correct lastID', function(done) {
12. 1 var stmt = db.prepare("INSERT INTO foo VALUES(?, ?)");
13. 1 var j = 1;
14. 5000 for (var i = 0; i < 5000; i++) {
15. 5000 stmt.run(i, "demo", function(err) {
16. 0 if (err) throw err;
17. 5000 // Relies on SQLite's row numbering to be gapless and starting
18. 5000 // from 1.
19. 5000 assert.equal(j++, this.lastID);
20. 5000 });
21. 5000 }
22. 1 db.wait(done);
23. 1 });
24. 1
25. 1 it('should return the correct changes count', function(done) {
26. 1 db.run("UPDATE foo SET id = id + 1 WHERE id % 2 = 0", function(err) {
27. 0 if (err) throw err;
28. 1 assert.equal(2500, this.changes);
29. 1 done();
30. 1 });
31. 1 });
32. 1});
33. 1