Mysql

Database configuration process is fun all the time with jswalker in multiple databases.

Configure

Create mysql database with proper credential & entry in entry-interface.js

database:{
    mongo_pool:{
      flag:true,
      dbs:[
        {name:"test",host:"127.0.0.1",port:27017,user:"root",password:"password"},
        {name:"test1",host:"127.0.0.1",port:27017,user:"root",password:"password"}
      ]
    },
    mysql_pool:{
      flag:true,
      dbs:[
        {prefix:"jswalker",name:"jswalker",host:"127.0.0.1",user:"root",password:"jas.1992"},
        {prefix:"test",name:"test",host:"127.0.0.1",user:"root",password:"password"},
      ]
    }
 }
              

How to use mysql in jswalker model

Jswalker mysql module is wrapped around jswalker-query module

Select


require("jswalker-query").select({
  query:"select query",
  system_op:system_op,
  nested_table:false,
  database:"database-name"
},function(op){
    /*op*/
});
          
Query

Pass variable which contain query or pass direct query string

system_op

Necessary to fetcg system variable in query module

nested_table

it is simply get all records with prefix table name when same fields of dofferent table required.

Callback

After query Executed callback call with followng details

op.flag : Contain true or false flag

op.res : Contain rows

op.query_trace : if anything goes wrong in query execution it will be useful tracing and get error object contain

controller_name : XXX
controller_line_number : XXX
model_name : XXX
controller_line_number : XXX
erro_stack : XXXX

Update


require("jswalker-query").update({
  query:"update query",
  system_op:system_op,
  database:"database-name"
},function(op){
    /*op*/
});
          
Query

Pass variable which contain query or pass direct query string

system_op

Necessary to fetcg system variable in query module

Callback

After query Executed callback call with followng details

op.flag : Contain true or false flag

op.res : Contain rows

op.query_trace : if anything goes wrong in query execution it will be useful tracing and get error object contain

controller_name : XXX
controller_line_number : XXX
model_name : XXX
controller_line_number : XXX
erro_stack : XXXX

delete


require("jswalker-query").delete({
  query:"delete query",
  system_op:system_op,
  database:"database-name"
},function(op){
    /*op*/
});
          
Query

Pass variable which contain query or pass direct query string

system_op

Necessary to fetcg system variable in query module

Callback

After query Executed callback call with followng details

op.flag : Contain true or false flag

op.res : Contain rows

op.query_trace : if anything goes wrong in query execution it will be useful tracing and get error object contain

controller_name : XXX
controller_line_number : XXX
model_name : XXX
controller_line_number : XXX
erro_stack : XXXX

Insert(Direct)


require("jswalker-query").insert({
  query:"insert query",
  system_op:system_op,
  database:"database-name"
},function(op){
    /*op*/
});
          

Insert(with object)


require("jswalker-query").insert({
  query:{field:value},
  table:"table-name",
  database:"database-name",
  system_op:system_op,
},function(op){
    /*op*/
});
          
Query

Pass variable which contain query or pass direct query string or pass field value object

table

table name is necessary when query is formed fiel:value object

system_op

Necessary to fetcg system variable in query module

system_op

Necessary to fetcg system variable in query module

Callback

After query Executed callback call with followng details

op.flag : Contain true or false flag

op.res : Contain rows

op.query_trace : if anything goes wrong in query execution it will be useful tracing and get error object contain

controller_name : XXX
controller_line_number : XXX
model_name : XXX
controller_line_number : XXX
erro_stack : XXXX

Plain Query module


require("jswalker-query").query({
  query:"Plain mysql query",
  database:"database-name",
  system_op:system_op,
},function(op){
    /*op*/
});
          
Query

Pass plain query string

system_op

Necessary to fetcg system variable in query module

Callback

After query Executed callback call with followng details

op.flag : Contain true or false flag

op.res : Contain rows

op.query_trace : if anything goes wrong in query execution it will be useful tracing and get error object contain

controller_name : XXX
controller_line_number : XXX
model_name : XXX
controller_line_number : XXX
erro_stack : XXXX