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

Commit 28c6574d by Sushant

docs: cleanup and fixes

1 parent 2343226d
......@@ -37,6 +37,7 @@ const sequelize = new Sequelize('database', 'username', 'password', {
pool: {
max: 5,
min: 0,
acquire: 30000,
idle: 10000
},
......@@ -120,7 +121,12 @@ const Post = sequelize.define('post', {}, {
## Promises
Sequelize uses promises to control async control-flow. If you are unfamiliar with how promises work, don't worry, you can read up on them [here](https://github.com/wbinnssmith/awesome-promises) and [here](http://bluebirdjs.com/docs/why-promises.html).
Sequelize uses [Bluebird](http://bluebirdjs.com) promises to control async control-flow.
**Note:** _Sequelize use independent copy of Bluebird instance. You can access it using
`Sequelize.Promise` if you want to set any Bluebird specific options_
If you are unfamiliar with how promises work, don't worry, you can read up on them [here](http://bluebirdjs.com/docs/why-promises.html).
Basically, a promise represents a value which will be present at some point - "I promise you I will give you a result or an error at some point". This means that
......
......@@ -9,17 +9,29 @@
[![npm](https://img.shields.io/npm/dm/sequelize.svg?style=flat-square)](https://npmjs.org/package/sequelize)
[![npm](https://img.shields.io/npm/v/sequelize.svg?style=flat-square)](https://github.com/sequelize/sequelize/releases)
Sequelize is a promise-based ORM for Node.js v4 and up. It supports the dialects PostgreSQL, MySQL, SQLite and MSSQL and features solid transaction support, relations, read replication and
more.
- [Getting Started](manual/installation/getting-started)
- [API Reference](identifiers)
Sequelize is a promise-based ORM for Node.js v4 and up. It supports the dialects PostgreSQL, MySQL, SQLite and MSSQL and features solid transaction support, relations, read replication and more.
## Example usage
```js
const Sequelize = require('sequelize');
const sequelize = new Sequelize('database', 'username', 'password');
const sequelize = new Sequelize('database', 'username', 'password', {
host: 'localhost',
dialect: 'mysql'|'sqlite'|'postgres'|'mssql',
pool: {
max: 5,
min: 0,
acquire: 30000,
idle: 10000
},
// SQLite only
storage: 'path/to/database.sqlite',
// http://docs.sequelizejs.com/manual/tutorial/querying.html#operators
operatorsAliases: false
});
const User = sequelize.define('user', {
username: Sequelize.STRING,
......@@ -32,8 +44,8 @@ sequelize.sync()
birthday: new Date(1980, 6, 20)
}))
.then(jane => {
console.log(jane.get({
plain: true
}));
console.log(jane.toJSON());
});
```
Please use [Getting Started](manual/installation/getting-started) to learn more. If you wish to learn about Sequelize API please use [API Reference](identifiers)
......@@ -292,20 +292,18 @@ Notice how in the two examples above, the string provided is inserted verbatim i
```js
something.findOne({
order: [
'name',
// will return `name`
'username DESC',
// will return `username DESC` -- i.e. don't do it!
['username', 'DESC'],
['name'],
// will return `username` DESC
sequelize.fn('max', sequelize.col('age')),
['username', 'DESC'],
// will return max(`age`)
[sequelize.fn('max', sequelize.col('age')), 'DESC'],
sequelize.fn('max', sequelize.col('age')),
// will return max(`age`) DESC
[sequelize.fn('otherfunction', sequelize.col('col1'), 12, 'lalala'), 'DESC'],
[sequelize.fn('max', sequelize.col('age')), 'DESC'],
// will return otherfunction(`col1`, 12, 'lalala') DESC
[sequelize.fn('otherfunction', sequelize.fn('awesomefunction', sequelize.col('col'))), 'DESC']
[sequelize.fn('otherfunction', sequelize.col('col1'), 12, 'lalala'), 'DESC'],
// will return otherfunction(awesomefunction(`col`)) DESC, This nesting is potentially infinite!
[sequelize.fn('otherfunction', sequelize.fn('awesomefunction', sequelize.col('col'))), 'DESC']
]
})
```
......
......@@ -453,12 +453,6 @@ HSTORE.prototype.validate = function validate(value) {
return true;
};
/**
* A JSON string column. Available in postgres, sqlite and MySQL.
*
* @function JSON
* @memberof DataTypes
*/
function JSONTYPE() {
if (!(this instanceof JSONTYPE)) return new JSONTYPE();
}
......
......@@ -4,6 +4,43 @@
* Operator symbols to be used when querying data
*
* @see {@link Model#where}
*
* @property eq
* @property ne
* @property gte
* @property gt
* @property lte
* @property lt
* @property not
* @property is
* @property in
* @property notIn
* @property like
* @property notLike
* @property iLike
* @property notILike
* @property regexp
* @property notRegexp
* @property iRegexp
* @property notIRegexp
* @property between
* @property notBetween
* @property overlap
* @property contains
* @property contained
* @property adjacent
* @property strictLeft
* @property strictRight
* @property noExtendRight
* @property noExtendLeft
* @property and
* @property or
* @property any
* @property all
* @property values
* @property col
* @property placeholder
* @property join
*/
const Op = {
eq: Symbol('eq'),
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!