Socket
Socket
Sign inDemoInstall

zeanium-node

Package Overview
Dependencies
Maintainers
1
Versions
142
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zeanium-node - npm Package Compare versions

Comparing version 0.6.47 to 0.6.48

2

package.json
{
"name": "zeanium-node",
"version": "0.6.47",
"version": "0.6.48",
"description": "Zeanium for Node.js, simple http server and custome your business.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -104,2 +104,73 @@ /**

});
},
moveNode: function (table, source, target){
var _fields = "id, zn_tree_pid, zn_tree_depth, zn_tree_order, zn_tree_son_count, zn_tree_max_son_count, zn_tree_parent_path";
return zn.createTransactionBlock()
.query(zn.sql.select({
table: table,
fields: _fields,
where: { id: source }
}) + zn.sql.select({
table: table,
fields: _fields,
where: { id: target }
})+"select max(zn_tree_order) as target_zn_tree_order from "+table+" where zn_tree_pid=" + target)
.query('order', function (sql, rows, fields){
var _source = rows[0][0],
_target = rows[1][0],
_target_zn_tree_order = rows[2][0].target_zn_tree_order;
if(_source.zn_tree_parent_path == _target.zn_tree_parent_path + _source.id + ','){
return this.rollback('The source has in target node!'), false;
}
if(!_target || !_source){
return this.rollback('The target or source is not exist!'), false;
}
var _sqls = [];
_sqls.push(zn.sql.update({
table: table,
updates: "zn_tree_son_count=zn_tree_son_count-1",
where: {
id: _source.zn_tree_pid
}
}));
_sqls.push(zn.sql.update({
table: table,
updates: {
zn_tree_pid: _target.id,
zn_tree_depth: _target.zn_tree_depth + 1,
zn_tree_order: _target_zn_tree_order + 1,
zn_tree_parent_path: _target.zn_tree_parent_path + _target.id + ','
},
where: {
id: _source.id
}
}));
_sqls.push(zn.sql.update({
table: table,
updates: {
zn_tree_son_count: _target.zn_tree_son_count + 1
},
where: {
id: _target.id
}
}));
_sqls.push(zn.sql.update({
table: table,
updates: "zn_tree_order=zn_tree_order-1",
where: "zn_tree_pid=" + _source.id + " and zn_tree_order>" + _source.zn_tree_order
}));
_sqls.push(zn.sql.update({
table: table,
updates: "zn_tree_parent_path=replace(zn_tree_parent_path, '"+_source.zn_tree_parent_path+"', '"+_target.zn_tree_parent_path + _target.id + ",')",
where: "locate('"+_source.zn_tree_parent_path + _source.id +"', zn_tree_parent_path)<>0"
}));
return _sqls.join('');
});
}

@@ -106,0 +177,0 @@ }

@@ -23,2 +23,16 @@ /**

},
moveTreeNode: function (source, target){
var _defer = zn.async.defer();
this.beginTransaction()
.block(zn.block.tree.moveNode(this._table, source, target))
.on('error', function (sender, error){
_defer.reject(error);
})
.on('finally', function (sender, data){
_defer.resolve(data);
})
.commit();
return _defer.promise;
},
insert: function (values){

@@ -25,0 +39,0 @@ var _defer = zn.async.defer();

@@ -181,3 +181,3 @@ /**

} else {
if(_callback && _callback.then) {
if(_callback && _callback.then && typeof _callback.then == 'function') {
_callback.then(function (data){

@@ -184,0 +184,0 @@ var _after = after && after.call(this, data);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc