Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mariadb

Package Overview
Dependencies
Maintainers
2
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mariadb - npm Package Compare versions

Comparing version 1.0.2 to 2.0.0-alpha

callback.js

66

package.json
{
"name": "mariadb",
"version": "1.0.2",
"description": "",
"main": "index.js",
"version": "2.0.0-alpha",
"description": "fast mariadb/mysql connector.",
"main": "promise.js",
"directories": {
"src": "src",
"test": "test"
},
"private": false,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "npm run test:lint && npm run test:prettier && npm run test:base",
"test:base": "mocha \"test/**/*.js\" ",
"test:lint": "eslint '{lib,test}/**/*.js'",
"test:prettier": "prettier --print-width 100 --trailing-comma none --write \"{lib,test,benchmarks}/**/*.js\"",
"coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls",
"benchmark": "node ./benchmarks/benchmarks.js",
"generate": "node ./tools/generate-mariadb.js"
},
"author": "PJ Briggs",
"license": "ISC"
"repository": {
"type": "git",
"url": "git+https://github.com/MariaDB/mariadb-connector-nodejs.git"
},
"keywords": [
"mariadb",
"mysql",
"client",
"driver",
"connector"
],
"files": [
"lib",
"promise.js",
"callback.js"
],
"engines": {
"node": ">= 6.0"
},
"author": "Diego Dupin <diego.dupin@mariadb.com>",
"license": "LGPL-2.1+",
"dependencies": {
"denque": "^1.3.0",
"iconv-lite": "^0.4.21",
"long": "^4.0.0",
"npm": "^6.1.0"
},
"devDependencies": {
"benchmark": "^2.1.4",
"chai": "^4.1.2",
"colors": "^1.2.1",
"error-stack-parser": "^2.0.1",
"eslint": "^4.19.1",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-markdown": "^1.0.0-beta.6",
"mocha": "^5.1.1",
"mocha-lcov-reporter": "^1.3.0",
"nyc": "^12.0.2",
"prettier": "^1.13.7"
},
"bugs": {
"url": "https://jira.mariadb.org/projects/CONJS/"
},
"homepage": "https://github.com/MariaDB/mariadb-connector-nodejs#readme"
}

@@ -1,1 +0,145 @@

This package is no longer dangerous.
<p align="center">
<a href="http://mariadb.org/">
<img src="https://mariadb.com/themes/custom/mariadb/logo.svg">
</a>
</p>
# MariaDB Node.js connector
[![Linux Build](https://travis-ci.org/MariaDB/mariadb-connector-nodejs.svg?branch=master)](https://travis-ci.org/MariaDB/mariadb-connector-nodejs)
[![Windows status](https://ci.appveyor.com/api/projects/status/bcg7yy4iy9viq08t/branch/master?svg=true)](https://ci.appveyor.com/project/rusher/mariadb-connector-nodejs)
[![License (LGPL version 2.1)](https://img.shields.io/badge/license-GNU%20LGPL%20version%202.1-green.svg?style=flat-square)](http://opensource.org/licenses/LGPL-2.1)
[![Coverage Status](https://coveralls.io/repos/github/MariaDB/mariadb-connector-nodejs/badge.svg?branch=master)](https://coveralls.io/github/MariaDB/mariadb-connector-nodejs?branch=master)
**Non-blocking MariaDB and MySQL client for Node.js.**
MariaDB and MySQL client, 100% JavaScript, compatible with Node.js 6+, with the Promise API.
## Why a New Client?
While there are existing MySQL clients that work with MariaDB, (such as the [`mysql`](https://www.npmjs.com/package/mysql) and [`mysql2`](https://www.npmjs.com/package/mysql2) clients), the MariaDB Node.js Connector offers new functionality, like [Insert Streaming](#insert-streaming) and [Pipelining](#pipelining) while making no compromises on performance.
### Insert Streaming
Using a Readable stream in your application, you can stream `INSERT` statements to MariaDB through the Connector.
```javascript
https.get('https://someContent', readableStream => {
//readableStream implement Readable, driver will stream data to database
connection.query("INSERT INTO myTable VALUE (?)", [readableStream]);
});
```
### Pipelining
With Pipelining, the Connector sends commands without waiting for server results, preserving order. For instance, consider the use of executing two `INSERT` statements.
<p align="center">
<img src="./documentation/misc/pip.png">
</p>
The Connector doesn't wait for query results before sending the next `INSERT` statement. Instead, it sends queries one after the other, avoiding much of the network latency.
For more information, see the [Pipelining](/documentation/piplining.md) documentation.
## Benchmarks
MariaDB provides benchmarks comparing the Connector with popular Node.js MySQL clients, including:
* [`promise-mysql`](https://www.npmjs.com/package/promise-mysql) version 3.3.1 + [`mysql`](https://www.npmjs.com/package/mysql) version 2.15.0
* [`mysql2`](https://www.npmjs.com/package/mysql2) version 1.5.3
```
promise-mysql : 1,366 ops/sec ±1.42%
mysql2 : 1,469 ops/sec ±1.63%
mariadb : 1,802 ops/sec ±1.19%
```
<img src="./documentation/misc/bench.png" width="559" height="209"/>
For more information, see the [Benchmarks](/documentation/benchmarks.md) page.
## Quick Start
The MariaDB Connector is available through the Node.js repositories. You can install it using npm :
```
$ npm install mariadb
```
Using ECMAScript < 2017:
```js
const mariadb = require('mariadb');
const pool = mariadb.createPool({host: 'mydb.com', user:' myUser', connectionLimit: 5});
pool.getConnection()
.then(conn => {
conn.query("SELECT 1 as val")
.then((rows) => {
console.log(rows); //[ {val: 1}, meta: ... ]
return conn.query("INSERT INTO myTable value (?, ?)", [1, "mariadb"]);
})
.then((res) => {
console.log(res); // { affectedRows: 1, insertId: 1, warningStatus: 0 }
conn.end();
})
.catch(err => {
//handle error
conn.end();
})
}).catch(err => {
//not connected
});
```
Using ECMAScript 2017:
```js
const mariadb = require('mariadb');
const pool = mariadb.createPool({host: 'mydb.com', user: 'myUser', connectionLimit: 5});
async function asyncFunction() {
let conn;
try {
conn = await pool.getConnection();
const rows = await conn.query("SELECT 1 as val");
console.log(rows); //[ {val: 1}, meta: ... ]
const res = await conn.query("INSERT INTO myTable value (?, ?)", [1, "mariadb"]);
console.log(res); // { affectedRows: 1, insertId: 1, warningStatus: 0 }
} catch (err) {
throw err;
} finally {
if (conn) return conn.end();
}
}
```
## Documentation
The MariaDB Node.js Connector can use different APIs on the back-end: Promise and Callback.
The default API is [Promise API](https://github.com/MariaDB/mariadb-connector-nodejs/blob/master/documentation/documentation/promise-api.md).
[Callback API](https://github.com/MariaDB/mariadb-connector-nodejs/blob/master/documentation/documentation/callback-api.md) is provided for compatibility with the `mysql` and `mysql2` APIs.
## Road Map
The Connector remains in development. Here's a list of features being developed for future releases:
* `PoolCluster`
* MariaDB `ed25519` plugin authentication
* Query Timeouts
* Bulk Insertion, (that is, fast batch).
## Contributing
If you would like to contribute to the MariaDB Node.js Connector, please follow the instructions given in the [Developers Guide.](/documentation/developers-guide.md)
To file an issue or follow the development, see [JIRA](https://jira.mariadb.org/projects/CONJS/issues/).
index.js
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc