package
sql
v0.72.0sql builder
- license
- MIT
- deps
- 2
- unpacked
- Unknown
- files
- Unknown
- node
- *
npm install sql@0.72.0README
GitHub-flavored package documentation.
downloads
Across all versions.
Download trend unavailable.
compatibility
Runtime metadata.
package
sql builder
npm install sql@0.72.0GitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
sql string builder for node - supports PostgreSQL, mysql, Microsoft SQL Server, Oracle and sqlite dialects.
Building SQL statements by hand is no fun, especially in a language which has clumsy support for multi-line strings.
So let's build it with JavaScript.
Maybe it's still not fun, but at least it's less not fun.
$ npm install sql//require the module
var sql = require('sql');
//(optionally) set the SQL dialect
sql.setDialect('postgres');
//possible dialects: mssql, mysql, postgres (default), sqlite
//first we define our tables
var user = sql.define({
name: 'user',
columns: ['id', 'name', 'email', 'lastLogin']
});
var post = sql.define({
name: 'post',
columns: ['id', 'userId', 'date', 'title', 'body'
There are a lot more examples included in the test/dialects folder. We encourage you to read through them if you have any questions on usage!
You can use the sql-generate module
to automatically generate definition files from a database instance. For example,
running node-sql-generate --dsn "mysql://user:password@host/database" will generate
something similar to:
// autogenerated by node-sql-generate v0.0.1 on Tue May 21 2013 01:04:12 GMT-0700 (PDT)
var sql = require('sql');
/**
* SQL definition for database.bar
*/
exports.bar = sql.define({
name: 'bar',
columns: [
'id',
'foo_id'
]
});
/**
* SQL definition for database.foo
*/
exports.foo = sql.define({
name: 'foo',
columns: [
'id',
'field_1',
'foo_bar_baz'
]
Read the module's documentation for more details.
We love contributions.
node-sql wouldn't be anything without all the contributors and collaborators who've worked on it. If you'd like to become a collaborator here's how it's done:
git pull https://github.com/(your_username)/node-sqlcd node-sqlnpm installnpm testAt this point the tests should pass for you. If they don't pass please open an issue with the output or you can even send me an email directly. My email address is on my github profile and also on every commit I contributed in the repo.
Once the tests are passing, modify as you see fit. Please make sure you write tests to cover your modifications. Once you're ready, commit your changes and submit a pull request.
As long as your pull request doesn't have completely off-the-wall changes and it does have tests we will almost always merge it and push it to npm
If you think your changes are too off-the-wall, open an issue or a pull-request without code so we can discuss them before you begin.
Usually after a few high-quality pull requests and friendly interactions we will gladly share collaboration rights with you.
After all, open source belongs to everyone.
MIT
Estimated unpacked size across 3 packages.
1.3 MB
Includes dependencies.
0.0.x
1.0.1