-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathindex.js
46 lines (40 loc) · 1.27 KB
/
index.js
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
/**
* puresql
* v 1.4.2
* Functional SQL abstraction for node.js (>6.0.0)
* Inspired by yesql (https://github.com/krisajenkins/yesql)
* Repository: https://github.com/neonerd/puresql
* Author: Andrej Sykora <as@andrejsykora.com>
* License: MIT License
*/
'use strict'
const file = require('./lib/file')
const query = require('./lib/query')
module.exports = {
// define a single query based on the passed sql string
defineQuery: function (sql) {
return query.makeQuery(sql)
},
// define multiple queries based on a single file
loadQueries: function (filePath) {
const queries = file.parseFile(filePath)
for (const key of Object.keys(queries)) {
queries[key] = query.makeQuery(queries[key])
}
return queries
},
// readymade adapters
// usage: require('puresql').adapters.mysql(mysqlConnection)
adapters: {
// mySQL using 'mysql' module
mysql: require('./lib/adapters/mysql'),
// SQLite using 'sqlite3' module
sqlite: require('./lib/adapters/sqlite'),
// msSQL experimental adapter using 'mssql' module
mssql: require('./lib/adapters/mssql'),
// Postgres experimental adapter using 'pg' module
pg: require('./lib/adapters/pg'),
// dummy adapter for testing purposes
test: require('./lib/adapters/test')
}
}