machinepack-waterline
v0.1.1
Published
A database-agnostic connectivity library for sending queries, managing dynamic db connections, committing/rolling back transactions, and more.
Downloads
2
Readme
Warning
Currently, this is experimental. See the Waterline driver interface for more information.
Example
Using .find()
Waterline.find({
model: 'users',
where: {
age: { '>': 50 },
preferredNumRazorBlades: { '>=': 3 }
}
}).setEnvironment({ sails: sails })
.exec(function (err){
// ...
});
Using .query()
Waterline.query({
datastore: 'ricksMySQLDb',
statement: {}
}).setEnvironment({ sails: sails })
.exec(function (err){
// ...
});
Using .connect()
Waterline.connect({
datastore: 'ricksMySQLDb',
during: function (connection, done) {
Waterline.find({
model: 'user',
connection: connection
})
.setEnvironment({ sails: sails })
.exec(done)
}
}).setEnvironment({ sails: sails })
.exec(function (err){
// ...
});
Using .transaction()
Waterline.transaction({
datastore: 'ricksMySQLDb',
during: function (connection, done) {
Waterline.find({
model: 'user',
connection: connection
})
.setEnvironment({ sails: sails })
.exec(done)
}
}).setEnvironment({ sails: sails })
.exec(function (err){
// ...
});
License
MIT © 2016 contributors