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

Commit 0a79ef81 by Brendan Jurd Committed by Sushant

docs: multiple grammar fixes (#8461)

1 parent e2dad2f9
...@@ -29,4 +29,4 @@ __Database version:__ XXX ...@@ -29,4 +29,4 @@ __Database version:__ XXX
__Sequelize version:__ XXX __Sequelize version:__ XXX
__Tested with master branch:__ No __Tested with master branch:__ No
**Note :** _Your issue may be ignored by maintainers if its not tested against `master` branch OR does not follow issue template._ **Note :** _Your issue may be ignored by maintainers if it's not tested against `master` branch OR does not follow issue template._
...@@ -540,7 +540,7 @@ task2.setProject(null).then(function() { ...@@ -540,7 +540,7 @@ task2.setProject(null).then(function() {
}) })
``` ```
For hasOne/belongsTo its basically the same: For hasOne/belongsTo it's basically the same:
```js ```js
Task.hasOne(User, {as: "Author"}) Task.hasOne(User, {as: "Author"})
...@@ -653,7 +653,7 @@ The relation between task and user injects the `user_id` foreign key on tasks, a ...@@ -653,7 +653,7 @@ The relation between task and user injects the `user_id` foreign key on tasks, a
For 1:1 and 1:m associations the default option is `SET NULL` for deletion, and `CASCADE` for updates. For n:m, the default for both is `CASCADE`. This means, that if you delete or update a row from one side of an n:m association, all the rows in the join table referencing that row will also be deleted or updated. For 1:1 and 1:m associations the default option is `SET NULL` for deletion, and `CASCADE` for updates. For n:m, the default for both is `CASCADE`. This means, that if you delete or update a row from one side of an n:m association, all the rows in the join table referencing that row will also be deleted or updated.
Adding constraints between tables means that tables must be created in the database in a certain order, when using `sequelize.sync`. If Task has a reference to User, the User table must be created before the Task table can be created. This can sometimes lead to circular references, where sequelize cannot find an order in which to sync. Imagine a scenario of documents and versions. A document can have multiple versions, and for convenience, a document has an reference to it's current version. Adding constraints between tables means that tables must be created in the database in a certain order, when using `sequelize.sync`. If Task has a reference to User, the User table must be created before the Task table can be created. This can sometimes lead to circular references, where sequelize cannot find an order in which to sync. Imagine a scenario of documents and versions. A document can have multiple versions, and for convenience, a document has a reference to its current version.
```js ```js
const Document = this.sequelize.define('document', { const Document = this.sequelize.define('document', {
......
...@@ -65,7 +65,7 @@ const User = sequelize.define('user', { ...@@ -65,7 +65,7 @@ const User = sequelize.define('user', {
} }
}); });
// Method 2 via the .hook() method (or it's alias .addHook() method) // Method 2 via the .hook() method (or its alias .addHook() method)
User.hook('beforeValidate', (user, options) => { User.hook('beforeValidate', (user, options) => {
user.mood = 'happy'; user.mood = 'happy';
}); });
...@@ -222,7 +222,7 @@ Model.update({username: 'Toni'}, { where: {accessLevel: 0}, individualHooks: tru ...@@ -222,7 +222,7 @@ Model.update({username: 'Toni'}, { where: {accessLevel: 0}, individualHooks: tru
// Will select all records that are about to be updated and emit before- + after- Update on each instance // Will select all records that are about to be updated and emit before- + after- Update on each instance
``` ```
The `options` argument of hook method would be the second argument provided to the corresponding method or it's The `options` argument of hook method would be the second argument provided to the corresponding method or its
cloned and extended version. cloned and extended version.
```js ```js
......
...@@ -79,7 +79,7 @@ This will do following ...@@ -79,7 +79,7 @@ This will do following
- Create a model file `user` in `models` folder - Create a model file `user` in `models` folder
- Create a migration file with name like `XXXXXXXXXXXXXX-create-user.js` in `migrations` folder - Create a migration file with name like `XXXXXXXXXXXXXX-create-user.js` in `migrations` folder
**Note:** _Sequelize will only use Model files, its the table representation. On other hand migration file is a change in that model or more specifically that table, used by CLI. Treat migrations like a commit or a log for some change in database._ **Note:** _Sequelize will only use Model files, it's the table representation. On other hand migration file is a change in that model or more specifically that table, used by CLI. Treat migrations like a commit or a log for some change in database._
### Running Migrations ### Running Migrations
Now till this step CLI haven't inserted anything into database. We have just created required model and migration files for our first model `User`. Now to actually create that table in database you need to run `db:migrate` command. Now till this step CLI haven't inserted anything into database. We have just created required model and migration files for our first model `User`. Now to actually create that table in database you need to run `db:migrate` command.
...@@ -323,7 +323,7 @@ module.exports = { ...@@ -323,7 +323,7 @@ module.exports = {
``` ```
### Specifying Dialect Options ### Specifying Dialect Options
Sometime you want to specify a dialectOption, if its a general config you can just add it in `config/config.json`. Sometime you want to execute some code to get dialectOptions, you should use dynamic config file for those cases. Sometime you want to specify a dialectOption, if it's a general config you can just add it in `config/config.json`. Sometime you want to execute some code to get dialectOptions, you should use dynamic config file for those cases.
```json ```json
{ {
......
...@@ -54,7 +54,7 @@ Model.findAll({ ...@@ -54,7 +54,7 @@ Model.findAll({
SELECT id, foo, bar, baz, quz, COUNT(hats) AS no_hats ... SELECT id, foo, bar, baz, quz, COUNT(hats) AS no_hats ...
``` ```
Similarly, its also possible to remove a selected few attributes: Similarly, it's also possible to remove a selected few attributes:
```js ```js
Model.findAll({ Model.findAll({
......
...@@ -167,7 +167,7 @@ allows the configuration of the transaction. ...@@ -167,7 +167,7 @@ allows the configuration of the transaction.
return sequelize.transaction({ /* options */ }); return sequelize.transaction({ /* options */ });
``` ```
The following options (with it's default values) are available: The following options (with their default values) are available:
```js ```js
{ {
......
...@@ -71,7 +71,7 @@ Sequelize V4 is a major release and it introduces new features and breaking chan ...@@ -71,7 +71,7 @@ Sequelize V4 is a major release and it introduces new features and breaking chan
- `DataTypes.DECIMAL` returns string for MySQL and Postgres. - `DataTypes.DECIMAL` returns string for MySQL and Postgres.
- `DataTypes.DATE` now uses `DATETIMEOFFSET` instead of `DATETIME2` sql datatype in case of MSSQL to record timezone. To migrate existing `DATETIME2` columns into `DATETIMEOFFSET`, see [#7201](https://github.com/sequelize/sequelize/pull/7201#issuecomment-278899803). - `DataTypes.DATE` now uses `DATETIMEOFFSET` instead of `DATETIME2` sql datatype in case of MSSQL to record timezone. To migrate existing `DATETIME2` columns into `DATETIMEOFFSET`, see [#7201](https://github.com/sequelize/sequelize/pull/7201#issuecomment-278899803).
- `options.order` now only accepts values with type of array or Sequelize method. Support for string values (ie `{order: 'name DESC'}`) has been deprecated. - `options.order` now only accepts values with type of array or Sequelize method. Support for string values (ie `{order: 'name DESC'}`) has been deprecated.
- With `BelongsToMany` relationships `add/set/create` setters now set through attributes by passing them as `options.through` (previously second argument was used as through attributes, now its considered options with `through` being a sub option) - With `BelongsToMany` relationships `add/set/create` setters now set through attributes by passing them as `options.through` (previously second argument was used as through attributes, now it's considered options with `through` being a sub option)
Previous: Previous:
```js ```js
......
...@@ -233,7 +233,7 @@ class ConnectionManager { ...@@ -233,7 +233,7 @@ class ConnectionManager {
} }
/** /**
* Get connection from pool. It set database version if its not already set. * Get connection from pool. It sets database version if it's not already set.
* Call pool.acquire to get a connection * Call pool.acquire to get a connection
* *
* @param {Object} [options] Pool options * @param {Object} [options] Pool options
......
...@@ -796,7 +796,7 @@ const QueryGenerator = { ...@@ -796,7 +796,7 @@ const QueryGenerator = {
// convert the item to an association // convert the item to an association
item = previousModel.associations[item]; item = previousModel.associations[item];
} else if (previousModel.rawAttributes !== undefined && previousModel.rawAttributes[item] && item !== previousModel.rawAttributes[item].field) { } else if (previousModel.rawAttributes !== undefined && previousModel.rawAttributes[item] && item !== previousModel.rawAttributes[item].field) {
// convert the item attribute from it's alias // convert the item attribute from its alias
item = previousModel.rawAttributes[item].field; item = previousModel.rawAttributes[item].field;
} else if ( } else if (
item.indexOf('.') !== -1 item.indexOf('.') !== -1
......
...@@ -375,7 +375,7 @@ class AbstractQuery { ...@@ -375,7 +375,7 @@ class AbstractQuery {
*/ */
/* /*
* Author (MH) comment: This code is an unreadable mess, but its performant. * Author (MH) comment: This code is an unreadable mess, but it's performant.
* groupJoinData is a performance critical function so we prioritize perf over readability. * groupJoinData is a performance critical function so we prioritize perf over readability.
*/ */
if (!rows.length) { if (!rows.length) {
......
...@@ -258,7 +258,7 @@ class Query extends AbstractQuery { ...@@ -258,7 +258,7 @@ class Query extends AbstractQuery {
} }
handleShowConstraintsQuery(data) { handleShowConstraintsQuery(data) {
//Convert snake_case keys to camelCase as its generated by stored procedure //Convert snake_case keys to camelCase as it's generated by stored procedure
return data.slice(1).map(result => { return data.slice(1).map(result => {
const constraint = {}; const constraint = {};
for (const key in result) { for (const key in result) {
......
...@@ -79,7 +79,7 @@ const QueryGenerator = { ...@@ -79,7 +79,7 @@ const QueryGenerator = {
if (options.uniqueKeys) { if (options.uniqueKeys) {
_.each(options.uniqueKeys, (columns, indexName) => { _.each(options.uniqueKeys, (columns, indexName) => {
if (!columns.singleField) { // If it's a single field its handled in column def, not as an index if (!columns.singleField) { // If it's a single field it's handled in column def, not as an index
if (!_.isString(indexName)) { if (!_.isString(indexName)) {
indexName = 'uniq_' + tableName + '_' + columns.fields.join('_'); indexName = 'uniq_' + tableName + '_' + columns.fields.join('_');
} }
......
...@@ -66,7 +66,7 @@ const QueryGenerator = { ...@@ -66,7 +66,7 @@ const QueryGenerator = {
if (options.uniqueKeys) { if (options.uniqueKeys) {
_.each(options.uniqueKeys, columns => { _.each(options.uniqueKeys, columns => {
if (!columns.singleField) { // If it's a single field its handled in column def, not as an index if (!columns.singleField) { // If it's a single field it's handled in column def, not as an index
values.attributes += ', UNIQUE (' + columns.fields.map(f => this.quoteIdentifiers(f)).join(', ') + ')'; values.attributes += ', UNIQUE (' + columns.fields.map(f => this.quoteIdentifiers(f)).join(', ') + ')';
} }
}); });
......
...@@ -61,7 +61,7 @@ const QueryGenerator = { ...@@ -61,7 +61,7 @@ const QueryGenerator = {
if (options.uniqueKeys) { if (options.uniqueKeys) {
_.each(options.uniqueKeys, columns => { _.each(options.uniqueKeys, columns => {
if (!columns.singleField) { // If it's a single field its handled in column def, not as an index if (!columns.singleField) { // If it's a single field it's handled in column def, not as an index
attrStr += ', UNIQUE (' + columns.fields.map(field => this.quoteIdentifier(field)).join(', ') + ')'; attrStr += ', UNIQUE (' + columns.fields.map(field => this.quoteIdentifier(field)).join(', ') + ')';
} }
}); });
......
...@@ -51,7 +51,7 @@ exports.removeColumn = removeColumn; ...@@ -51,7 +51,7 @@ exports.removeColumn = removeColumn;
@for QueryInterface @for QueryInterface
@param {String} tableName The name of the table. @param {String} tableName The name of the table.
@param {Object} attributes An object with the attribute's name as key and it's options as value object. @param {Object} attributes An object with the attribute's name as key and its options as value object.
@param {Object} options @param {Object} options
@param {Boolean|Function} [options.logging] A function that logs the sql queries, or false for explicitly not logging these queries @param {Boolean|Function} [options.logging] A function that logs the sql queries, or false for explicitly not logging these queries
......
...@@ -235,7 +235,7 @@ class ValidationErrorItem { ...@@ -235,7 +235,7 @@ class ValidationErrorItem {
this.type = type || null; this.type = type || null;
this.path = path || null; this.path = path || null;
this.value = value !== undefined ? value : null; this.value = value !== undefined ? value : null;
//This doesn't need captureStackTrace because its not a subclass of Error //This doesn't need captureStackTrace because it's not a subclass of Error
} }
} }
exports.ValidationErrorItem = ValidationErrorItem; exports.ValidationErrorItem = ValidationErrorItem;
......
...@@ -294,7 +294,7 @@ class Model { ...@@ -294,7 +294,7 @@ class Model {
} }
if (types !== true) { if (types !== true) {
// replace type placeholder e.g. 'One' with it's constituent types e.g. 'HasOne', 'BelongsTo' // replace type placeholder e.g. 'One' with its constituent types e.g. 'HasOne', 'BelongsTo'
all.splice(i, 1); all.splice(i, 1);
i--; i--;
for (let j = 0; j < types.length; j++) { for (let j = 0; j < types.length; j++) {
...@@ -466,7 +466,7 @@ class Model { ...@@ -466,7 +466,7 @@ class Model {
if (include.attributes.length) { if (include.attributes.length) {
_.each(include.model.primaryKeys, (attr, key) => { _.each(include.model.primaryKeys, (attr, key) => {
// Include the primary key if its not already take - take into account that the pk might be aliassed (due to a .field prop) // Include the primary key if it's not already included - take into account that the pk might be aliased (due to a .field prop)
if (!_.some(include.attributes, includeAttr => { if (!_.some(include.attributes, includeAttr => {
if (attr.field !== key) { if (attr.field !== key) {
return Array.isArray(includeAttr) && includeAttr[0] === attr.field && includeAttr[1] === key; return Array.isArray(includeAttr) && includeAttr[0] === attr.field && includeAttr[1] === key;
...@@ -3265,7 +3265,7 @@ class Model { ...@@ -3265,7 +3265,7 @@ class Model {
this._setInclude(key, value, options); this._setInclude(key, value, options);
return this; return this;
} else { } else {
// Bunch of stuff we won't do when its raw // Bunch of stuff we won't do when it's raw
if (!options.raw) { if (!options.raw) {
// If attribute is not in model definition, return // If attribute is not in model definition, return
if (!this._isAttribute(key)) { if (!this._isAttribute(key)) {
......
...@@ -305,7 +305,7 @@ function getFunctionCode(fn) { ...@@ -305,7 +305,7 @@ function getFunctionCode(fn) {
} }
/** /**
* Returns arguments of a function as an array, from it's AST * Returns arguments of a function as an array, from its AST
* *
* @param {Object} tree - Abstract syntax tree of function's code * @param {Object} tree - Abstract syntax tree of function's code
* @returns {Array} - Array of names of `method`'s arguments * @returns {Array} - Array of names of `method`'s arguments
......
...@@ -47,7 +47,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -47,7 +47,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}); });
describe('attributes', () => { describe('attributes', () => {
it('should not inject the aliassed PK again, if its already there', function() { it('should not inject the aliased PK again, if it\'s already there', function() {
let options = Sequelize.Model._validateIncludedElements({ let options = Sequelize.Model._validateIncludedElements({
model: this.User, model: this.User,
include: [ include: [
......
...@@ -374,7 +374,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -374,7 +374,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
expect(options.include[0]).to.deep.equal({ model: Project, where: { something: true }}); expect(options.include[0]).to.deep.equal({ model: Project, where: { something: true }});
}); });
it('should be able to merge aliassed includes with the same model', () => { it('should be able to merge aliased includes with the same model', () => {
const scope = { const scope = {
include: [{model: User, as: 'someUser'}] include: [{model: User, as: 'someUser'}]
}; };
......
...@@ -25,7 +25,7 @@ suite(Support.getTestDialectTeaser('SQL'), () => { ...@@ -25,7 +25,7 @@ suite(Support.getTestDialectTeaser('SQL'), () => {
}; };
testsql({ testsql({
limit: 10, //when no order by present, one is automagically prepended, test it's existence limit: 10, //when no order by present, one is automagically prepended, test its existence
model:{primaryKeyField:'id', name:'tableRef'} model:{primaryKeyField:'id', name:'tableRef'}
}, { }, {
default: ' LIMIT 10', default: ' LIMIT 10',
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!