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

Commit 8cea0fcf by Mick Hansen

Merge pull request #3029 from toastynerd/doc_typo_fix

fix typo in docs
2 parents 6e2a0144 e86a33f4
Showing with 6 additions and 6 deletions
...@@ -474,7 +474,7 @@ Task.drop() // will emit success or failure event ...@@ -474,7 +474,7 @@ Task.drop() // will emit success or failure event
Project.[sync|drop]().then(function() { Project.[sync|drop]().then(function() {
// ok ... everything is nice! // ok ... everything is nice!
}).catch(function(error) { }).catch(function(error) {
// oooh, did you entered wrong database credentials? // oooh, did you enter wrong database credentials?
}) })
``` ```
...@@ -584,7 +584,7 @@ Project.find({ ...@@ -584,7 +584,7 @@ Project.find({
### findOrCreate - Search for a specific element or create it if not available ### findOrCreate - Search for a specific element or create it if not available
The method `findOrCreate` can be used to check if a certain element is already existing in the database. If that is the case the method will result in a respective instance. If the element does not yet exist, it will be created. The method `findOrCreate` can be used to check if a certain element already exists in the database. If that is the case the method will result in a respective instance. If the element does not yet exist, it will be created.
Let's assume we have an empty database with a `User` model which has a `username` and a `job`. Let's assume we have an empty database with a `User` model which has a `username` and a `job`.
...@@ -637,7 +637,7 @@ User ...@@ -637,7 +637,7 @@ User
### findAndCountAll - Search for multiple elements in the database, returns both data and total count ### findAndCountAll - Search for multiple elements in the database, returns both data and total count
This is a convienience method that combines`findAll()`and`count()`(see below), this is useful when dealing with queries related to pagination where you want to retrieve data with a`limit`and`offset`but also need to know the total number of records that match the query. This is a convienience method that combines`findAll`()and `count`()(see below), this is useful when dealing with queries related to pagination where you want to retrieve data with a `limit` and `offset` but also need to know the total number of records that match the query.
The success handler will always receive an object with two properties: The success handler will always receive an object with two properties:
...@@ -660,7 +660,7 @@ Project ...@@ -660,7 +660,7 @@ Project
}); });
``` ```
The options [object] that you pass to`findAndCountAll()`is the same as for`findAll()`(described below). The options [object] that you pass to`findAndCountAll`()is the same as for`findAll`()(described below).
### findAll - Search for multiple elements in the database ### findAll - Search for multiple elements in the database
```js ```js
...@@ -900,7 +900,7 @@ Project.sum('age', { where: { age: { gt: 5 } } }).then(function(sum) { ...@@ -900,7 +900,7 @@ Project.sum('age', { where: { age: { gt: 5 } } }).then(function(sum) {
## Eager loading ## Eager loading
When you are retrieving data from the database there is a fair chance that you also want to get their associations. This is possible since`v1.6.0`and is called eager loading. The basic idea behind that, is the use of the attribute`include`when you are calling`find`or`findAll`. Lets assume the following setup: When you are retrieving data from the database there is a fair chance that you also want to get their associations. This is possible since`v1.6.0`and is called eager loading. The basic idea behind that, is the use of the attribute `include` when you are calling `find` or `findAll`. Lets assume the following setup:
```js ```js
var User = sequelize.define('User', { name: Sequelize.STRING }) var User = sequelize.define('User', { name: Sequelize.STRING })
...@@ -968,7 +968,7 @@ User.findAll({ include: [ Task ] }).then(function(users) { ...@@ -968,7 +968,7 @@ User.findAll({ include: [ Task ] }).then(function(users) {
Notice that the accessor is plural. This is because the association is many-to-something. Notice that the accessor is plural. This is because the association is many-to-something.
If an association is aliased (using the`as`option), you_must_specify this alias when including the model. Notice how the user's`Tool`s are aliased as`Instruments`above. In order to get that right you have to specify the model you want to load, as well as the alias: If an association is aliased (using the`as`option), you must specify this alias when including the model. Notice how the user's `Tool`s are aliased as `Instruments` above. In order to get that right you have to specify the model you want to load, as well as the alias:
```js ```js
User.findAll({ include: [{ model: Tool, as: 'Instruments' }] }).then(function(users) { User.findAll({ include: [{ model: Tool, as: 'Instruments' }] }).then(function(users) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!