@ac-moore-inc/mssql-wrapper 中文文档教程
MSSQL Wrapper
一个易于使用的 MSSQL 包装器。
由 AC Moore 软件工程团队创建和维护。
Methods
prepareService
为提供的数据库创建连接池连接
prepareService(config, callback);
Parameters:
config: object
需要包含与数据库相关信息的配置对象。
config Example:
{
databaseName: {
'user': 'db_user_name',
'password': 'db_pass',
'server': 'PATH\\TOSERVER'
'database': 'DATABASE_NAME'
'pool': {
'max': 10,
'min': 4,
'idleTimeoutMillis': 30000
}
},
other db connections...
}
executePSQuery
执行准备好的语句
executePSQuery(options, callback);
Parameters:
options: Object
Field | Type | Required | Value |
---|---|---|---|
db | string | true | database name as defined in the config object used to prepare the service |
qrydata | object | true | object containing query fields, fromobjects, and whereclause |
server | string | false | sever location of the database |
input | array | false | array of objects containing input name and type (as defined by mssql) |
params | object | false | key value pairs defining any parameters, where key is the given input name and value is the parameter value |
exeuteSP
执行存储过程
executeSP(options, callback);
Parameters:
options: Object
Field | Type | Required | Value |
---|---|---|---|
db | string | true | database name as defined in the config object used to prepare the service |
procedure | string | true | procedure name |
input | array | false | array of objects containing input name, type (as defined by mssql), and value (key: val) |
output | array | false | array of objects containing output name and type (as defined by mssql) |
executeQuery
调用基本查询
executeQuery(options, callback);
Parameters:
options: Object
Field | Type | Required | Value |
---|---|---|---|
db | string | true | database name as defined in the config object used to prepare the service |
qrydata | array | true | array of objects containing query: fields, fromobjects, joincondition, whereclause, groupby, order_by |
server | string | false | sever location of the database |
outFormat | array | false | array of objects containing output name and type (as defined by mssql) |
MSSQL Wrapper
An easy to use MSSQL wrapper.
Created and maintained by the A.C. Moore software engineering team.
Methods
prepareService
Create the connection pools for provided databases
prepareService(config, callback);
Parameters:
config: object
A configuration object containing information related to the database is required to connect.
config Example:
{
databaseName: {
'user': 'db_user_name',
'password': 'db_pass',
'server': 'PATH\\TOSERVER'
'database': 'DATABASE_NAME'
'pool': {
'max': 10,
'min': 4,
'idleTimeoutMillis': 30000
}
},
other db connections...
}
executePSQuery
Execute prepared statement
executePSQuery(options, callback);
Parameters:
options: Object
Field | Type | Required | Value |
---|---|---|---|
db | string | true | database name as defined in the config object used to prepare the service |
qrydata | object | true | object containing query fields, fromobjects, and whereclause |
server | string | false | sever location of the database |
input | array | false | array of objects containing input name and type (as defined by mssql) |
params | object | false | key value pairs defining any parameters, where key is the given input name and value is the parameter value |
exeuteSP
Execute a stored procedure
executeSP(options, callback);
Parameters:
options: Object
Field | Type | Required | Value |
---|---|---|---|
db | string | true | database name as defined in the config object used to prepare the service |
procedure | string | true | procedure name |
input | array | false | array of objects containing input name, type (as defined by mssql), and value (key: val) |
output | array | false | array of objects containing output name and type (as defined by mssql) |
executeQuery
call a basic query
executeQuery(options, callback);
Parameters:
options: Object
Field | Type | Required | Value |
---|---|---|---|
db | string | true | database name as defined in the config object used to prepare the service |
qrydata | array | true | array of objects containing query: fields, fromobjects, joincondition, whereclause, groupby, order_by |
server | string | false | sever location of the database |
outFormat | array | false | array of objects containing output name and type (as defined by mssql) |