MySQL adapter for the Sails framework and Waterline ORM. Allows you to use MySQL via your models to store and retrieve data. Also provides a query()
method for a direct interface to execute raw SQL commands.
New comparator notLike.
.where({ name: { notLike: 'A%' } })
Custom SQL Support/Hack.
.where({ sql: 'LENGTH(name) > 3' })
Custom JOIN + WHERE Support/Hack (gigatec/waterline needed).
Table1.find(null, {
join_sql: [ 'LEFT JOIN table2 ON table2.id = table1.id', 'LEFT JOIN table3 ON table2.id = table1.id' ],
where_sql: [ 'table2.active = 1', 'table3.enabled = 1' ]
})
Install from NPM.
# In your app:
$ npm install sails-mysql
Add the mysql config to the config/adapters.js file. Basic options:
module.exports.adapters = {
'default': 'mysql',
mysql: {
module : 'sails-mysql',
host : 'localhost',
port : 3306,
user : 'username',
password : 'password',
database : 'MySQL Database Name'
// OR (explicit sets take precedence)
module : 'sails-mysql',
url : 'mysql2://USER:PASSWORD@HOST:PORT/DATABASENAME'
}
};
You can set environment variables to override the default database config for the tests, e.g.:
$ WATERLINE_ADAPTER_TESTS_PASSWORD=yourpass npm test
Default settings are:
{
host: process.env.WATERLINE_ADAPTER_TESTS_HOST || 'localhost',
port: process.env.WATERLINE_ADAPTER_TESTS_PORT || 3306,
user: process.env.WATERLINE_ADAPTER_TESTS_USER || 'root',
password: process.env.WATERLINE_ADAPTER_TESTS_PASSWORD || '',
database: process.env.WATERLINE_ADAPTER_TESTS_DATABASE || 'sails_mysql',
pool: true,
connectionLimit: 10,
waitForConnections: true
}
- Stackoverflow
- #sailsjs on Freenode (IRC channel)
- Professional/enterprise
- Tutorials
- Waterline (ORM)
MIT © 2014 Mike McNeil, Balderdash & contributors
Sails is free and open-source under the MIT License.
See the MySQL Logo Usage Guidelines for more information on our use of the MySQL logo.