loopback-connector-mysql/README.md

53 lines
1.5 KiB
Markdown
Raw Permalink Normal View History

# loopback-connector-mysql
2012-12-14 14:01:44 +00:00
`loopback-connector-mysql` is the MySQL connector module for [loopback-datasource-juggler](https://github.com/strongloop/loopback-datasource-juggler/).
For complete documentation, see [StrongLoop Documentation | MySQL Connector](http://loopback.io/doc/en/lb2/MySQL-connector.html).
2012-12-14 14:01:44 +00:00
## Installation
````sh
npm install loopback-connector-mysql --save
````
## Basic use
2012-12-14 14:01:44 +00:00
To use it you need `loopback-datasource-juggler`.
2012-12-14 14:01:44 +00:00
1. Setup dependencies in `package.json`:
```json
{
...
"dependencies": {
"loopback-datasource-juggler": "latest",
2013-07-22 00:27:54 +00:00
"loopback-connector-mysql": "latest"
2012-12-14 14:01:44 +00:00
},
...
}
```
2. Use:
```javascript
2013-09-24 22:14:23 +00:00
var DataSource = require('loopback-datasource-juggler').DataSource;
var dataSource = new DataSource('mysql', {
2013-10-14 22:19:04 +00:00
host: 'localhost',
port: 3306,
2013-10-03 21:50:38 +00:00
database: 'mydb',
username: 'myuser',
password: 'mypass'
2012-12-14 14:01:44 +00:00
});
```
2013-10-03 21:50:38 +00:00
You can optionally pass a few additional parameters supported by [`node-mysql`](https://github.com/felixge/node-mysql),
2013-09-24 22:14:23 +00:00
most particularly `password` and `collation`. `Collation` currently defaults
to `utf8_general_ci`. The `collation` value will also be used to derive the
connection charset.
2012-12-14 14:01:44 +00:00
## Running Tests
2015-03-18 05:27:30 +00:00
The tests in this repository are mainly integration tests, meaning you will need to run them using our preconfigured test server.
2015-03-18 05:26:09 +00:00
1. Ask a core developer for instructions on how to set up test server credentials on your machine
2. `npm test`