You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

asyncplify-mssql

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asyncplify-mssql

asyncplify mssql operators for quering, updating sql databases

0.5.5
latest
Source
npmnpm
Version published
Weekly downloads
4
-76.47%
Maintainers
1
Weekly downloads
 
Created
Source

asyncplify-mssql

asyncplify mssql operators for quering, updating sql databases.

Installation

npm install asyncplify-mssql

Documentation

bulk

Asynchronously insert records using bulk insert to a table in a database.

options:

  • columns: Array of string
  • create: Boolean default = false: true to create the table if it does not exists
  • size: Number default = 5000: the paging size
  • table: String

Example:

	asyncplifyMssql
		.connect({ 
			server: 'localhost',
			database: 'db-here',
			user: 'user-here',
			password: 'pw-here'
		})
		.flatMap(function (connection) {
			return asyncplify
				.range(2)
				.map(function (x) { return { id: x, name: 'Record #' + x }; })
				.pipe(connection.bulk({
					columns: {
						id: 'bigint NOT NULL',
						name: 'nvarchar(50) NOT NULL'
					},
					create: true,
					table: 'bulk-test'
				}))
				.finally(connection.close);
		})
		.subscribe(console.log.bind(console));
// { id: 0, name: 'Record #0' }
// { id: 1, name: 'Record #1' }

insert(table)

Asynchronously insert records into a database table.

options:

  • table: String

Example:

	asyncplifyMssql
		.connect({ 
			server: 'localhost',
			database: 'db-here',
			user: 'user-here',
			password: 'pw-here'
		})
		.flatMap(function (connection) {
			return asyncplify
				.range(2)
				.map(function (x) { return { id: x, name: 'Record #' + x }; })
				.pipe(connection.insert('myTable'))
				.finally(connection.close);
		})
		.subscribe(console.log.bind(console));
// { id: 0, name: 'Record #0' }
// { id: 1, name: 'Record #1' }
// end.

enableIndexes(options)

Enable or disable sql indexes on a table.

options:

  • enabled: Boolean default = false, use true to enable/rebuild, false to disable
  • table: String

Example:

	asyncplifyMssql
		.connect({ 
			server: 'localhost',
			database: 'db-here',
			user: 'user-here',
			password: 'pw-here'
		})
		.flatMap(function (connection) {
			return connection
				.enableIndexes({ table: 'my-table', enabled: false })
				.finally(connection.close);
		})
		.subscribe(console.log.bind(console));
// { name: 'IX_INDEX1, table: 'my-table' }
// { name: 'IX_INDEX2, table: 'my-table' }
// end.

query(sql, params)

Asynchronously execute a request.

options:

  • batch: Boolean default = false, by default(false) use execute_sql to enable query plan.
  • sql String
  • parameters

Example:

	asyncplifyMssql
		.connect({ 
			server: 'localhost',
			database: 'db-here',
			user: 'user-here',
			password: 'pw-here'
		})
		.flatMap(function (connection) {
			return connection
				.query('SELECT id, name FROM Table1 ORDER BY id')
				.finally(connection.close);
		})
		.subscribe(console.log.bind(console));
// { id: 1, name: 'Record 1' }
// { id: 2, name: 'Record 2' }
// { id: 3, name: 'Record 3' }
// { id: 4, name: 'Record 4' }
// end.

License

The MIT License (MIT)

Copyright (c) 2015 Dany Laporte

Keywords

asyncplify

FAQs

Package last updated on 02 Aug 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts