mirror of
https://gitlab.com/Shinobi-Systems/ShinobiCE.git
synced 2025-03-09 15:40:15 +00:00
Shinobi CE officially lands on Gitlab
This commit is contained in:
commit
f1406d4eec
431 changed files with 118157 additions and 0 deletions
37
INSTALL/installDatabase.js
Normal file
37
INSTALL/installDatabase.js
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
var knex = require('knex');
|
||||
if(config.databaseType===undefined){config.databaseType='mysql'}
|
||||
|
||||
var databaseOptions = {
|
||||
client: config.databaseType,
|
||||
connection: config.db,
|
||||
}
|
||||
if(databaseOptions.client.indexOf('sqlite')>-1){
|
||||
databaseOptions.client = 'sqlite3';
|
||||
databaseOptions.useNullAsDefault = true;
|
||||
}
|
||||
if(databaseOptions.client === 'sqlite3' && databaseOptions.connection.filename === undefined){
|
||||
databaseOptions.connection.filename = __dirname+"/shinobi.sqlite"
|
||||
}
|
||||
s.databaseEngine = knex(databaseOptions)
|
||||
s.sqlQuery = function(query,values,onMoveOn,hideLog){
|
||||
if(!values){values=[]}
|
||||
if(typeof values === 'function'){
|
||||
var onMoveOn = values;
|
||||
var values = [];
|
||||
}
|
||||
if(!onMoveOn){onMoveOn=function(){}}
|
||||
return s.databaseEngine.raw(query,values)
|
||||
.asCallback(function(err,r){
|
||||
if(err&&config.databaseLogs){
|
||||
s.systemLog('s.sqlQuery QUERY',query)
|
||||
s.systemLog('s.sqlQuery ERROR',err)
|
||||
}
|
||||
if(onMoveOn)
|
||||
if(typeof onMoveOn === 'function'){
|
||||
if(!r)r=[]
|
||||
onMoveOn(err,r)
|
||||
}else{
|
||||
console.log(onMoveOn)
|
||||
}
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue