不要怂,就是干,撸起袖子干!

Commit a6b169e3 by Jan Aagaard Meier

Merge pull request #2821 from crwhite21/update-usage-doc

Update usage doc
2 parents d6ca4299 22e37fe7
Showing with 18 additions and 8 deletions
...@@ -119,7 +119,7 @@ var sequelize = new Sequelize('database', 'username', 'password', { ...@@ -119,7 +119,7 @@ var sequelize = new Sequelize('database', 'username', 'password', {
## Read replication ## Read replication
Sequelize supports read replication, i.e. having multiple servers that you can connect to when you want to do a SELECT query. When you do read replication, you specify one or more servers to act as read replicas, and one server to act as the write master, which handles all writes and updates and propagates them to the replicas (note that the actual replication process is**not **handled by Sequelize, but should be set up in MySql). Sequelize supports read replication, i.e. having multiple servers that you can connect to when you want to do a SELECT query. When you do read replication, you specify one or more servers to act as read replicas, and one server to act as the write master, which handles all writes and updates and propagates them to the replicas (note that the actual replication process is **not** handled by Sequelize, but should be set up in MySql).
```js ```js
var sequelize = new Sequelize('database', null, null, { var sequelize = new Sequelize('database', null, null, {
...@@ -139,7 +139,7 @@ var sequelize = new Sequelize('database', null, null, { ...@@ -139,7 +139,7 @@ var sequelize = new Sequelize('database', null, null, {
}) })
``` ```
If you have any general settings that apply to all replicas you do not need to provide them for each instance. In the code above, database name and port is propagated to all replicas. The same will happen for user and password, if you leave them out for any of the replicas. Each replica has the following options:`host`,`port`,`username`,`password`,`database` If you have any general settings that apply to all replicas you do not need to provide them for each instance. In the code above, database name and port is propagated to all replicas. The same will happen for user and password, if you leave them out for any of the replicas. Each replica has the following options:`host`,`port`,`username`,`password`,`database`.
Sequelize uses a pool to manage connections to your replicas. The default options are: Sequelize uses a pool to manage connections to your replicas. The default options are:
...@@ -157,11 +157,11 @@ If you want to modify these, you can pass pool as an options when instanti ...@@ -157,11 +157,11 @@ If you want to modify these, you can pass pool as an options when instanti
## Dialects ## Dialects
With the release of Sequelize`v1.6.0`, the library got independent from specific dialects. This means, that you'll have to add the respective connector library to your project yourself. Version 1.7.0 stable has been released in bundles with the connector libraries (sequelize-mysql, sequelize-postgres etc.) but these bundles are not maintained, and will not be released for 2.0.0 upwards. With the release of Sequelize`1.6.0`, the library got independent from specific dialects. This means, that you'll have to add the respective connector library to your project yourself. Version 1.7.0 stable has been released in bundles with the connector libraries (sequelize-mysql, sequelize-postgres etc.) but these bundles are not maintained, and will not be released for 2.0.0 upwards.
### MySQL ### MySQL
In order to get Sequelize working nicely together with MySQL, you'll need to install`mysql@~2.0.0-alpha7`or higher. Once that's done you can use it like this: In order to get Sequelize working nicely together with MySQL, you'll need to install`mysql@~2.5.0`or higher. Once that's done you can use it like this:
```js ```js
var sequelize = new Sequelize('database', 'username', 'password', { var sequelize = new Sequelize('database', 'username', 'password', {
...@@ -178,7 +178,7 @@ for examples (currently only mysql and mariadb are supported). ...@@ -178,7 +178,7 @@ for examples (currently only mysql and mariadb are supported).
### MariaDB ### MariaDB
For MariaDB compatibility you have to install the package `mariasql@0.1.20`, or higher. For MariaDB compatibility you have to install the package `mariasql@~0.1.20`.
The configuration needs to look like this: The configuration needs to look like this:
```js ```js
...@@ -189,7 +189,7 @@ var sequelize = new Sequelize('database', 'username', 'password', { ...@@ -189,7 +189,7 @@ var sequelize = new Sequelize('database', 'username', 'password', {
### SQLite ### SQLite
For SQLite compatibility you'll need`sqlite3@~2.1.5`. Configure Sequelize like this: For SQLite compatibility you'll need`sqlite3@~3.0.0`. Configure Sequelize like this:
```js ```js
var sequelize = new Sequelize('database', 'username', 'password', { var sequelize = new Sequelize('database', 'username', 'password', {
...@@ -204,7 +204,7 @@ var sequelize = new Sequelize('database', 'username', 'password', { ...@@ -204,7 +204,7 @@ var sequelize = new Sequelize('database', 'username', 'password', {
### PostgreSQL ### PostgreSQL
The library for PostgreSQL is`pg@~2.0.0`. You'll just need to define the dialect: The library for PostgreSQL is`pg@~3.6.0` You'll just need to define the dialect:
```js ```js
var sequelize = new Sequelize('database', 'username', 'password', { var sequelize = new Sequelize('database', 'username', 'password', {
...@@ -213,9 +213,19 @@ var sequelize = new Sequelize('database', 'username', 'password', { ...@@ -213,9 +213,19 @@ var sequelize = new Sequelize('database', 'username', 'password', {
}) })
``` ```
### MSSQL
The library for MSSQL is`tedious@^1.7.0` You'll just need to define the dialect:
```js
var sequelize = new Sequelize('database', 'username', 'password', {
dialect: 'mssql'
})
```
## Executing raw SQL queries ## Executing raw SQL queries
As there are often use cases in which it is just easier to execute raw / already prepared SQL queries, you can utilize the function`sequelize.query`. As there are often use cases in which it is just easier to execute raw / already prepared SQL queries, you can utilize the function`sequelize.query`.
Here is how it works: Here is how it works:
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!