Giter Site home page Giter Site logo

sails-mysql's Introduction

Sails-MySQL Adapter Powered by MySQL

Build Status npm version dependencies

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.

Installation

Install from NPM.

# In your app:
$ npm install sails-mysql

Sails Configuration

Add the mysql config to the config/connections.js file. Basic options:

module.exports.connections = {
  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'
    
    // Optional
    charset   : 'utf8',
    collation : 'utf8_swedish_ci'
  }
};

And then change default model configuration to the config/models.js:

module.exports.models = {
  connection: 'mysql'
};

Run tests

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
}

More Resources

License

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.

image_squidhome@2x.png

githalytics.com alpha

sails-mysql's People

Contributors

code-vicar avatar connor4312 avatar devinivy avatar dmarcelino avatar dqydj avatar eddieajau avatar feldsam avatar gaugendre avatar gigonaut avatar gmgjy avatar hiro-nakamura avatar huafu avatar jjshoe avatar kenhunt avatar leedm777 avatar madd0g avatar mikermcneil avatar miklos-martin avatar npfitz avatar particlebanana avatar ruffrey avatar sgress454 avatar stt avatar tarlepp avatar tauren avatar tjwebb avatar tomgiddings avatar tuukkat avatar uzyn avatar vanetix avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.