3.0.2 • Published 8 months ago
mssql-cr-layer v3.0.2
mssql-cr-layer
(https://coveralls.io/repos/github/andrglo/mssql-cr-layer/badge.svg?branch=master)](https://coveralls.io/github/andrglo/mssql-cr-layer?branch=master)
A MS SQL Server interface layer for common requests. It uses mssql to connect and wraps it in a tiny layer using ES2015 promises with the goal to be simpler and compatible with pg via pg-cr-layer
Install
$ npm install --save mssql-cr-layerUsage
var mssqlCrLayer = require('mssql-cr-layer');
var config = {
user: 'me',
password: 'my password',
host: 'localhost',
port: 1433,
pool: {
max: 25,
idleTimeout: 30000
}
};
var layer = new MssqlCrLayer(config)
layer.connect()
.then(function() {
return layer.execute('CREATE TABLE products ( ' +
'product_no integer, ' +
'name varchar(10), ' +
'price numeric(12,2) )');
})
.then(function() {
return layer.transaction(function(t) {
return layer
.execute('INSERT INTO products VALUES (1, \'Cheese\', 9.99)', null, {transaction: t})
.then(function() {
return layer.execute('INSERT INTO products VALUES (2, \'Chicken\', 19.99)', null, {transaction: t})
})
.then(function() {
return layer
.execute('INSERT INTO products VALUES ($1, $2, $3)', [3, 'Duck', 0.99], {transaction: t})
});
})
})
.then(function() {
return layer.query('SELECT * FROM products WHERE product_no=@product_no',
{product_no: {value: 1, type: 'integer'}}) // or just {product_no: 1}
.then(function(recordset) {
console.log(recordset[0]); // => { product_no: 1, name: 'Cheese', price: 9.99 }
})
})
.then(function() {
return layer.close();
})
.catch(function(error) {
console.log(error);
});License
MIT © Andre Gloria
3.0.2
8 months ago
3.0.1
1 year ago
3.0.0
2 years ago
2.0.19
3 years ago
2.0.18
3 years ago
2.0.17
3 years ago
2.0.15
3 years ago
2.0.16
3 years ago
2.0.13
4 years ago
2.0.14
4 years ago
2.0.12
4 years ago
2.0.11
4 years ago
2.0.10
4 years ago
2.0.9
5 years ago
2.0.8
5 years ago
2.0.7
6 years ago
2.0.6
6 years ago
2.0.5
6 years ago
2.0.4
6 years ago
2.0.3
6 years ago
2.0.2
6 years ago
2.0.1
7 years ago
2.0.0
8 years ago
1.0.10
9 years ago
1.0.9
9 years ago
1.0.8
9 years ago
1.0.7
9 years ago
1.0.6
9 years ago
1.0.5
10 years ago
1.0.3
10 years ago
1.0.2
10 years ago
1.0.1
10 years ago
0.0.7
10 years ago
0.0.6
10 years ago
0.0.5
10 years ago
0.0.4
10 years ago
0.0.3
10 years ago
0.0.2
10 years ago
0.0.1
10 years ago