https://github.com/faust64/someql
NodeJS postgre/mysql/sqlite/cassandra abstraction library
https://github.com/faust64/someql
Last synced: 6 months ago
JSON representation
NodeJS postgre/mysql/sqlite/cassandra abstraction library
- Host: GitHub
- URL: https://github.com/faust64/someql
- Owner: faust64
- License: bsd-3-clause
- Created: 2018-01-07T08:09:18.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2024-06-16T11:05:12.000Z (over 1 year ago)
- Last Synced: 2025-03-20T22:49:55.141Z (9 months ago)
- Language: JavaScript
- Size: 335 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# SQL Abstraction Library
* Last tests against master on CircleCI: [](https://circleci.com/gh/faust64/someql)
* Install with: `npm install someql`
* Write backend-agnostic code:
```
// cassandra
const db = require'someql')({ driver: 'cassandra', database: 'tests', username: 'casuser', password: 'caspass', host: '3.4.5.6' });
// mysql
const db = require('someql')({ driver: 'mysql', database: 'tests', username: 'myuser', password: 'mypass', host: '2.3.4.5' });
// postgres
const db = require('someql')({ driver: 'postgres', database: 'tests', username: 'pguser', password: 'pgpass', host: '1.2.3.4', ssl: true });
// defaults to sqlite
const db = require('someql')({ database: './default.sqlite' });
db.read(`SELECT * from sometable`)
.then((rsp) => {
if (rsp !== undefined && rsp[0] !== undefined) {
for (let i = 0, i < rsp.length; i++) {
doSomethingWith(rsp[0]);
}
return db.write(`INSERT INTO othertable (name, otherfield) VALUES ('toto', false)`);
}
})
.then(() => whatver())
.catch((e) => {
console.error('failed querying DB');
console.error(e);
});
```