-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathsqlite3.js
More file actions
57 lines (47 loc) · 1.91 KB
/
sqlite3.js
File metadata and controls
57 lines (47 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
var sqlite3 = module.exports = exports = require('./sqlite3_bindings');
var sys = require("sys");
var Database = sqlite3.Database;
var Statement = sqlite3.Statement;
// Database#prepare(sql, [bind1, bind2, ...], [callback])
Database.prototype.prepare = function(sql) {
var callback, params = Array.prototype.slice.call(arguments, 1);
if (!params.length || (params.length === 1 && typeof params[0] === 'function')) {
return new Statement(this, sql, params[0]);
}
else {
var statement = new Statement(this, sql);
return statement.bind.apply(statement, params);
}
};
// Database#run(sql, [bind1, bind2, ...], [callback])
Database.prototype.run = function(sql) {
var statement = new Statement(this, sql);
statement.run.apply(statement, Array.prototype.slice.call(arguments, 1)).finalize();
return this;
}
// Database#get(sql, [bind1, bind2, ...], [callback])
Database.prototype.get = function(sql) {
var statement = new Statement(this, sql);
statement.get.apply(statement, Array.prototype.slice.call(arguments, 1)).finalize();
return this;
}
// Database#all(sql, [bind1, bind2, ...], [callback])
Database.prototype.all = function(sql) {
var statement = new Statement(this, sql);
statement.all.apply(statement, Array.prototype.slice.call(arguments, 1)).finalize();
return this;
}
// Database#each(sql, [bind1, bind2, ...], [callback])
Database.prototype.each = function(sql) {
var statement = new Statement(this, sql);
statement.each.apply(statement, Array.prototype.slice.call(arguments, 1)).finalize();
return this;
}
Database.prototype.execute = function() {
console.warn('Database#execute() is deprecated. Use Database#all() instead.');
return this.all.apply(this, arguments);
};
Database.prototype.query = function() {
console.warn('Database#query() is deprecated. Use Database#each() instead.');
return this.each.apply(this, arguments);
};