viva-server-mssql
v3.1.1
Published
library for work with Microsoft SQL Server
Downloads
174
Maintainers
Keywords
Readme
Classes
Functions
Typedefs
Server_mssql
(license MIT) library for work with Microsoft SQL Server, full example - see example.js
Kind: global class
- Server_mssql
- .connected : boolean
- .timezone_offset : number
- .init(connection_config, callback)
- .exec(queries, [options], callback)
- .action_add(action) ⇒ string
- .action_del(key)
- .action_check(key) ⇒ type_action_find
- .action_exec(key, params, callback)
- .schedule_go(job)
- .schedule_delete(job_key)
- .get_newid(callback)
- .date_in_sql([d]) ⇒ Date
server_mssql.connected : boolean
Kind: instance property of Server_mssql
server_mssql.timezone_offset : number
Kind: instance property of Server_mssql
server_mssql.init(connection_config, callback)
init library, check connect to MS SQL Server
Kind: instance method of Server_mssql
| Param | Type | Description | | --- | --- | --- | | connection_config | type_connection_config | connection setting | | callback | callback_error | |
server_mssql.exec(queries, [options], callback)
exec query or queries
Kind: instance method of Server_mssql
| Param | Type | Description | | --- | --- | --- | | queries | string | Array.<string> | query or array of queries (for run on one open connection) | | [options] | type_exec_option | | | callback | callback_exec | |
exec~exec_result
Kind: inner property of exec
Privare: @type {type_exec_result}
server_mssql.action_add(action) ⇒ string
add one action
Kind: instance method of Server_mssql
Returns: string - error that prevented load action
| Param | Type | Description | | --- | --- | --- | | action | type_action | single action |
server_mssql.action_del(key)
delete action from list
Kind: instance method of Server_mssql
| Param | Type | Description | | --- | --- | --- | | key | string | action key |
server_mssql.action_check(key) ⇒ type_action_find
find action key and load errors
Kind: instance method of Server_mssql
| Param | Type | Description | | --- | --- | --- | | key | string | action key |
server_mssql.action_exec(key, params, callback)
exec action
Kind: instance method of Server_mssql
| Param | Type | Description | | --- | --- | --- | | key | string | uniq key of action | | params | any | | | callback | callback_action | |
server_mssql.schedule_go(job)
add new schedule or replace existsing schedule
Kind: instance method of Server_mssql
| Param | Type | | --- | --- | | job | lib_vschedule.type_job |
server_mssql.schedule_delete(job_key)
remove existsing schedule
Kind: instance method of Server_mssql
| Param | Type | | --- | --- | | job_key | string |
server_mssql.get_newid(callback)
get new guid
Kind: instance method of Server_mssql
| Param | Type | Description | | --- | --- | --- | | callback | callback_get_newid | error, guid |
server_mssql.date_in_sql([d]) ⇒ Date
get date in ms sql server
Kind: instance method of Server_mssql
| Param | Type | Description | | --- | --- | --- | | [d] | Date | local date regarding which to get the date on the server, default - now |
clone_table(from) ⇒ type_exec_table_result
Kind: global function
| Param | Type | | --- | --- | | from | type_exec_table_result |
noname_row_beautify(table, type_ext)
Kind: global function
| Param | Type | | --- | --- | | table | type_exec_table_result | | type_ext | boolean |
find_disappeared_numbers(nums) ⇒ Array.<number>
Kind: global function
| Param | Type | | --- | --- | | nums | Array.<number> |
type_connection_config
Kind: global typedef
Properties
| Name | Type | Description | | --- | --- | --- | | server | string | MS SQL instance, for example - 'server\instance1' | | password | string | passrord for ms sql authentication or windows authentication | | [login] | string | login for ms sql authentication, if empty - os authentication | | database | string | name database for connect, default - 'tempdb' | | [app_name] | string | app name, which will be visible in profiler | | [connection_timeout] | number | connection timeout in milliseconds, default - 15000 | | [execution_timeout] | number | execution timeout in milliseconds, default - 0 (infinity) | | [encrypt_connection] | boolean | encrypt connection, default - false | | [useUTC] | boolean | default - true | | [action_allow] | boolean | use action subsystem, default - false | | [again_connect_count] | number | count to try to connect to the server if the connection is unavailable, default - 0 (again try connect is disabled) | | [again_connect_timeout] | number | timeout in milliseconds between attempts to connect to the server, default - 2000 |
type_action
Kind: global typedef
Properties
| Name | Type | Description | | --- | --- | --- | | key | string | action uniq key | | sql_script | string | | | [sql_param] | string | | | [sql_param_note] | string | | | [sql_result] | string | | | [sql_lock] | string | one thread - name | | [sql_lock_wait] | number | one thread - wait timeout in milliseconds (0 - no wait), default 0 | | [sql_lock_message] | string | one thread - message if lock exists | | [js_script] | string | | | title | string | action title | | [note] | string | action title | | [keys_next] | string | exec this actions after exec this action, example - 'key1;key2' | | [correction_utc_mode] | string | | | [extented_property] | Object | |
type_generate_class_with_exec_actions
Kind: global typedef
Properties
| Name | Type | | --- | --- | | [action_class_template] | string | | [class_name] | string |
callback_empty : function
Kind: global typedef
callback_error : function
Kind: global typedef
| Param | Type | | --- | --- | | error | Error |
type_exec_option
Kind: global typedef
Properties
| Name | Type | Description | | --- | --- | --- | | [correction_utc] | type_exec_correction_utc_option | | | [lock] | type_exec_lock_option | one thread subsystem | | [noname_row_beautify] | boolean | default - false | | [chunk_rows] | number | return result by chunk, default - off (undefined) | | [chunk_msec] | number | return result by chunk, default - off (undefined) | | [check_database_after_exec] | boolean | return database name, which is active at the time the script is finished, default - false | | [check_spid] | boolean | return spid, for (example) kill process, default - false | | [check_print] | boolean | return PRINT and RAISERROR, default - false | | [type_ext] | boolean | create properties "type_name", "type_title", "type_charlen" in schema |
type_exec_lock_option
Kind: global typedef
Properties
| Name | Type | | --- | --- | | [key] | string | | [wait] | number | | [message] | string |
type_exec_lock_result
Kind: global typedef
Properties
| Name | Type | | --- | --- | | [key] | string | | [wait] | number | | [message] | string | | allow | boolean |
type_exec_correction_utc_option
Kind: global typedef
Properties
| Name | Type | Description | | --- | --- | --- | | [offset] | number | correct field with datetime type by this value (in minutes) | | [mode] | string | which fields correct by utc offset, example - '{#all}{}{fdm;ldm}' - in first table correct all datetime fields, second table is missing, in the third table correct only two fields |
type_exec_correction_utc_result
Kind: global typedef
Properties
| Name | Type | Description | | --- | --- | --- | | [offset] | number | correct field with datetime type by this value (in minutes) | | [mode] | string | which fields correct by utc offset, example - '{#all}{}{fdm;ldm}' - in first table correct all datetime fields, second table is missing, in the third table correct only two fields |
type_exec_error_result
Kind: global typedef
Properties
| Name | Type | | --- | --- | | step | number | | error | Error | | point | 'connect' | 'sql' | 'kill' | 'action' |
type_exec_script_result
Kind: global typedef
Properties
| Name | Type | | --- | --- | | [lock_on] | string | | [lock_off] | string | | queue | Array.<string> | | [name_server] | string | | [name_database] | string | | [name_database_after_exec] | string | | [spid] | number | | [spguid] | string | | get_plain_query | function |
type_exec_table_result
Kind: global typedef
Properties
| Name | Type | | --- | --- | | schema | Object | | step | number | | table_index | number | | rows | Array.<Object> |
function_tables_to_xml_file1 : function
Kind: global typedef
| Param | Type | | --- | --- | | error | Error | | xml | string |
function_tables_to_xml_file2 : function
Kind: global typedef
| Param | Type | Description | | --- | --- | --- | | [full_file_name] | string | //if empty, see xml as a string in callback | | table_name_list | Array.<string> | | | callback | function_tables_to_xml_file1 | |
type_performance
Kind: global typedef
Properties
| Name | Type | | --- | --- | | perfomance_exec_before | number | | perfomance_exec_after | number | | duration_exec_millisecond | Array.<number> |
type_exec_result
Kind: global typedef
Properties
| Name | Type | | --- | --- | | handle_error | type_exec_error_result | | [lock] | type_exec_lock_result | | [script] | type_exec_script_result | | [correction_utc] | type_exec_correction_utc_result | | performance | type_performance | | [tables] | Array.<type_exec_table_result> | | [tables_to_xml] | function_tables_to_xml_file2 |
type_exec_runtime
Kind: global typedef
Properties
| Name | Type | | --- | --- | | type | 'spid' | 'print' | 'table' | | [spid] | type_exec_spid | | [print] | type_exec_print | | [table] | type_exec_table_result |
type_exec_spid
Kind: global typedef
Properties
| Name | Type | | --- | --- | | spguid | string | | spid | number | | exists | boolean | | killed | boolean |
type_exec_print
Kind: global typedef
Properties
| Name | Type | | --- | --- | | message | string | | procname | string | | is_error | boolean |
callback_exec_part : function
Kind: global typedef
| Param | Type | | --- | --- | | error | Object |
callback_exec : function
Kind: global typedef
| Param | Type | | --- | --- | | result | type_exec_result | | runtime | type_exec_runtime |
callback_exec_runtime : function
Kind: global typedef
| Param | Type | | --- | --- | | runtime | type_exec_runtime |
callback_print : function
Kind: global typedef
| Param | Type | | --- | --- | | print | type_exec_print |
callback_table : function
Kind: global typedef
| Param | Type | | --- | --- | | table | type_exec_table_result |
callback_action : function
Kind: global typedef
| Param | Type | | --- | --- | | result | type_exec_result | | named_tables | Array.<Object> | | warning | Array.<string> |
callback_get_connection_pool : function
Kind: global typedef
| Param | Type | | --- | --- | | error | Error | | connection_pool | lib_sql.ConnectionPool |
callback_connect : function
Kind: global typedef
| Param | Type | | --- | --- | | error | Error | | connection_pool | lib_sql.Request |
type_action_find
Kind: global typedef
Properties
| Name | Type | | --- | --- | | key | string | | title | string | | sql_result_list | Array.<string> | | note | string | | error_list | Array.<string> |
callback_get_newid : function
Kind: global typedef
| Param | Type | | --- | --- | | error | Error | | guid | string |