
Security News
PodRocket Podcast: Inside the Recent npm Supply Chain Attacks
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
This is extremely experimental stuff
This is a simple "mybatis-like" dao for nodejs.
npm install nobatis
or
npm install git@github.com:iolo/node-nobatis.git
var config = {
"dataSource": {
"driver": "mariasql",
"host": "localhost",
"port": 3306,
"user": "root",
"password": "",
"db": "test"
},
"queries": {
"test1.selectAll": "SELECT * FROM test1",
"test1.select": "SELECT * FROM test1 WHERE id=?",
"test1.insert": "INSERT INTO test1(name) VALUES(:name)",
"test1.update": "UPDATE test1 SET name=:name WHERE id=:id",
"test1.delete": "DELETE FROM test1 WHERE id=?"
}
};
or you can write configurations to a file(json module). 3. import nobatis module
var nobatis = require('nobatis');
DataSource
with configutaion:
var dataSource = nobatis.createDataSource(config);
or create one with a configuration file(json module):
var dataSource = nobatis.createDataSource(require('./config'));
or get the default one:
var dataSource = nobatis.createDataSource();
openSession()
:
var session = null;
try {
session = dataSource.openSession();
// use session here …
} finally {
session && session.close();
}
or withSession()
:
dataSource.withSession(function (session) {
// use session here ...
});
session.select('test1.selectAll', [])
.then(function(rows) {
...
}).fail(function(err) {
...
});
session.select('test1.selectAll', [], {offset:2, limit:2})
.then(function(rows) {
...
})
.fail(function(err) {
...
});
session.selectOne('test1.select', \[1])
.then(function(row) {
...
.fail(function(err) {
...
});
session.insert('test1.insert', {name:'a'})
.then(function(insertId) {
...
.fail(function(err) {
...
});
session.update('test1.update', {id:1, name:'a'})
.then(function(affectedRows) {
...
.fail(function(err) {
...
});
session.destroy('test1.delete', \[1])
.then(function(affectedRows) {
...
.fail(function(err) {
...
});
var nobatis = require('nobatis');
var dataSource = require('nobatis').createDataSource(config);
var dao = nobatis.createDao(dataSource, {
table: 'test1',
primaryKey: 'id',
primaryKeyGenerated: true,
defaults: function () {
return {
id: 0,
name: '',
created: new Date()
};
}
});
var obj = dao.createNew();
var obj = dao.createNew({name:'foo'});
dao.isNew(obj);
dao.load(pk)
.then(function (obj) {
...
.fail(function(err) {
...
});
dao.save(obj)
.then(function (affectedRow-or-insertId) {
...
.fail(function(err) {
...
});
dao.save(obj, true)
.then(function (obj) {
...
.fail(function(err) {
...
});
dao.destroy(pk)
.then(function (success_or_not) {
...
.fail(function(err) {
...
});
dao.all()
.then(function (rows) {
...
.progress(function (row) {
...
.fail(function(err) {
...
});
dao.all({offset:10, limit:10})
.then(function (rows, numRows) {
...
.progress(function (row) {
...
.fail(function(err) {
...
});
see also [https://github.com/kriskowal/q]
TBW
FAQs
simple mybatis-like dao for nodejs
We found that nobatis demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.