Comparing version 0.0.1 to 0.0.2
@@ -213,3 +213,3 @@ var sqlite3 = require('sqlite3'); | ||
self.save = function(data) { | ||
if(utils.isObject(fields) === false) { | ||
if(utils.isObject(data) === false) { | ||
throw Error("Save requires a hash of fields=>values to update to"); | ||
@@ -216,0 +216,0 @@ } |
{ | ||
"name": "litesql", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "The easy way to deal with sqlite databases in node.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -9,6 +9,8 @@ ## What's this ? | ||
basically, litesql intends to brings the same interface into sqlite database. undeway the module use the [sqlite3][sqlite3] | ||
basically, litesql intends to brings the same interface into sqlite database. undeway the module use the [sqlite3][sqlite3] module, meaning you can access all the functions it offers. | ||
[sqlite3]: https://github.com/mapbox/node-sqlite3 | ||
Of course you may also use the additional facilities this module offers (otherwise, you wouldn't be here, right?) | ||
## Getting started | ||
@@ -28,10 +30,18 @@ | ||
db.createTable( | ||
'todos', // table name | ||
{ // table defintion | ||
id: 'pk', // shortcut for id INTEGER PRIMARY KEY AUTOINCREMENT | ||
task: { type: 'text', required: true }, // you can pass it also 'unique: true' | ||
// table name | ||
'todos', | ||
// table defintion | ||
{ | ||
// shortcut for id INTEGER PRIMARY KEY AUTOINCREMENT | ||
id: 'pk', | ||
// column definition can be an object too; you can pass it also 'unique: true' | ||
task: { type: 'text', required: true }, | ||
// type alias is managed internally by the library | ||
duedate: 'date', | ||
completed: 'boolean' // type alias is managed internally | ||
completed: 'boolean' | ||
} | ||
).run(); | ||
).run(); | ||
/* | ||
@@ -57,3 +67,7 @@ you can also write | ||
``` | ||
So basically, it works always the way you've seen it | ||
- Construct a query via helper methods and classes | ||
- then execute the query using methods like you are used to ( run, get, all, each ) | ||
## Documentation | ||
More to come soon; for now, you may take a look on the tests to see how it's been used |
@@ -439,37 +439,4 @@ var assert = require("assert") | ||
} | ||
} | ||
} | ||
it('should create a table and insert data into it', function(done) { | ||
db.serialize(function() { | ||
db.createTable( | ||
'todos', // table name | ||
{ // table defintion | ||
id: 'pk', // shortcut for id INTEGER PRIMARY KEY AUTOINCREMENT | ||
task: { type: 'text', required: true }, // you can pass it also 'unique: true' | ||
duedate: 'date', | ||
completed: 'boolean' // types alias are managed internally | ||
} | ||
).run(); | ||
/* | ||
you can also write | ||
var query = db.createTable(...); | ||
query.run( function (err) { ... } ); | ||
*/ | ||
// helper class | ||
var todos = new litesql.Table('todos', 'id', db); | ||
for(var i = 1; i <= 10; i++) { | ||
todos.insert({ task: 'Task #'+i, duedate: new Date(), completed: false }).run(); | ||
} | ||
todos.find().all( function(err, tasks){ | ||
assert.equal(err, null); | ||
assert.equal(tasks.length, 10); | ||
done(); | ||
}); | ||
}) | ||
}); | ||
it( "should upgrade model", function(done) { | ||
@@ -476,0 +443,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45246
8
983
71