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

Commit 5a807c51 by Simon Schick Committed by GitHub

docs: remove remaining bluebird references (#12167)

1 parent 7610345e
......@@ -23,7 +23,7 @@ We're glad to get pull request if any functionality is missing or something is b
* Make sure that all existing tests pass
* Make sure you followed [coding guidelines](https://github.com/sequelize/sequelize/blob/master/CONTRIBUTING.md#coding-guidelines)
* Add some tests for your new functionality or a test exhibiting the bug you are solving. Ideally all new tests should not pass _without_ your changes.
- Use [promise style](http://bluebirdjs.com/docs/why-promises.html) in all new tests. Specifically this means:
- Use [async/await](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function) in all new tests. Specifically this means:
- don't use `EventEmitter`, `QueryChainer` or the `success`, `done` and `error` events
- don't use a done callback in your test, just return the promise chain.
- Small bugfixes and direct backports to the 4.x branch are accepted without tests.
......
......@@ -104,8 +104,8 @@ const sequelize = new Sequelize('sqlite::memory:', {
});
```
## Bluebird Promises and async/await
## Promises and async/await
Most of the methods provided by Sequelize are asynchronous and therefore return Promises. They are all [Bluebird](http://bluebirdjs.com) Promises, so you can use the rich Bluebird API (for example, using `finally`, `tap`, `tapCatch`, `map`, `mapSeries`, etc) out of the box. You can access the Bluebird constructor used internally by Sequelize with `Sequelize.Promise`, if you want to set any Bluebird specific options.
Most of the methods provided by Sequelize are asynchronous and therefore return Promises. They are all [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) , so you can use the Promise API (for example, using `then`, `catch`, `finally`) out of the box.
Of course, using `async` and `await` works normally as well.
\ No newline at end of file
Of course, using `async` and `await` works normally as well.
......@@ -8,9 +8,8 @@ As Sequelize heavily relies on runtime property assignments, TypeScript won't be
In order to avoid installation bloat for non TS users, you must install the following typing packages manually:
- `@types/node` (this is universally required)
- `@types/node` (this is universally required in node projects)
- `@types/validator`
- `@types/bluebird`
## Usage
......@@ -129,8 +128,6 @@ Address.belongsTo(User, {targetKey: 'id'});
User.hasOne(Address,{sourceKey: 'id'});
async function stuff() {
// Please note that when using async/await you lose the `bluebird` promise context
// and you fall back to native
const newUser = await User.create({
name: 'Johnny',
preferredName: 'John',
......
......@@ -1146,12 +1146,6 @@
"integrity": "sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==",
"dev": true
},
"@types/bluebird": {
"version": "3.5.30",
"resolved": "https://registry.npmjs.org/@types/bluebird/-/bluebird-3.5.30.tgz",
"integrity": "sha512-8LhzvcjIoqoi1TghEkRMkbbmM+jhHnBokPGkJWjclMK+Ks0MxEBow3/p2/iFTZ+OIbJHQDSfpgdZEb+af3gfVw==",
"dev": true
},
"@types/color-name": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz",
......
......@@ -47,7 +47,6 @@
"devDependencies": {
"@commitlint/cli": "^8.3.5",
"@commitlint/config-angular": "^8.3.4",
"@types/bluebird": "^3.5.26",
"@types/node": "^12.12.37",
"@types/validator": "^10.11.0",
"acorn": "^7.1.1",
......
......@@ -15,6 +15,5 @@ export * from './lib/associations/index';
export * from './lib/errors';
export { BaseError as Error } from './lib/errors';
export { useInflection } from './lib/utils';
export { Promise } from './lib/promise';
export { Utils, QueryTypes, Op, TableHints, IndexHints, DataTypes, Deferrable };
export { Validator as validator } from './lib/utils/validator-extras';
......@@ -11,8 +11,6 @@ import {
Transactionable,
WhereOptions,
} from '../model';
import { Promise } from '../promise';
import { Transaction } from '../transaction';
import { Association, AssociationScope, ForeignKeyOptions, ManyToManyOptions, MultiAssociationAccessors } from './base';
/**
......@@ -21,7 +19,7 @@ import { Association, AssociationScope, ForeignKeyOptions, ManyToManyOptions, Mu
export interface ThroughOptions {
/**
* The model used to join both sides of the N:M association.
* Can be a string if you want the model to be generated by sequelize.
* Can be a string if you want the model to be generated by sequelize.
*/
model: typeof Model | string;
......
import { DataType } from '../data-types';
import { CreateOptions, FindOptions, Model, ModelCtor, SaveOptions } from '../model';
import { Promise } from '../promise';
import { Association, AssociationOptions, SingleAssociationAccessors } from './base';
// type ModelCtor<M extends Model> = InstanceType<typeof M>;
......
......@@ -8,7 +8,6 @@ import {
ModelCtor,
Transactionable,
} from '../model';
import { Promise } from '../promise';
import { Association, ManyToManyOptions, MultiAssociationAccessors } from './base';
/**
......
import { DataType } from '../data-types';
import { CreateOptions, FindOptions, Model, ModelCtor, SaveOptions } from '../model';
import { Promise } from '../promise';
import { Association, AssociationOptions, SingleAssociationAccessors } from './base';
/**
......
import { Promise } from './promise';
export interface GetConnectionOptions {
/**
* Set which replica to use. Available options are `read` and `write`
......
......@@ -4,9 +4,8 @@ import { DataType } from './data-types';
import { Deferrable } from './deferrable';
import { HookReturn, Hooks, ModelHooks } from './hooks';
import { ValidationOptions } from './instance-validator';
import { Promise } from './promise';
import { QueryOptions, IndexesOptions } from './query-interface';
import { Config, Options, Sequelize, SyncOptions } from './sequelize';
import { Sequelize, SyncOptions } from './sequelize';
import { Transaction, LOCK } from './transaction';
import { Col, Fn, Literal, Where } from './utils';
import Op = require('./operators');
......
// tslint:disable-next-line:no-implicit-dependencies
import * as Bluebird from 'bluebird';
export const Promise: typeof Bluebird;
export type Promise<T> = Bluebird<T>;
export default Promise;
import { DataType } from './data-types';
import { Logging, Model, ModelAttributeColumnOptions, ModelAttributes, Transactionable, WhereOptions, Filterable, Poolable } from './model';
import { Promise } from './promise';
import QueryTypes = require('./query-types');
import { Sequelize, RetryOptions } from './sequelize';
import { Transaction } from './transaction';
......
import * as DataTypes from './data-types';
import * as Deferrable from './deferrable';
import { HookReturn, Hooks, SequelizeHooks } from './hooks';
import { ValidationOptions } from './instance-validator';
import {
......@@ -23,15 +22,10 @@ import {
Hookable,
} from './model';
import { ModelManager } from './model-manager';
import * as Op from './operators';
import { Promise } from './promise';
import { QueryInterface, QueryOptions, QueryOptionsWithModel, QueryOptionsWithType } from './query-interface';
import QueryTypes = require('./query-types');
import { Transaction, TransactionOptions } from './transaction';
import { Cast, Col, Fn, Json, Literal, Where } from './utils';
// tslint:disable-next-line:no-duplicate-imports
import * as Utils from './utils';
import { validator } from './utils/validator-extras';
import { ConnectionManager } from './connection-manager';
/**
......@@ -777,7 +771,7 @@ export class Sequelize extends Hooks {
/**
* Use CLS with Sequelize.
* CLS namespace provided is stored as `Sequelize._cls`
* and bluebird Promise is patched to use the namespace, using `cls-bluebird` module.
* and Promise is patched to use the namespace, using `cls-hooked` module.
*
* @param namespace
*/
......
import { Deferrable } from './deferrable';
import { Logging } from './model';
import { Promise } from './promise';
import { Sequelize } from './sequelize';
/**
......
......@@ -115,5 +115,3 @@ export class Where extends SequelizeMethod {
constructor(attr: object, comparator: string, logic: string | object);
constructor(attr: object, logic: string | object);
}
export { Promise } from './promise';
import { Model, Promise, Op } from 'sequelize';
import { Model, Op } from 'sequelize';
class MyModel extends Model {}
......
......@@ -120,8 +120,6 @@ Address.belongsTo(User, {targetKey: 'id'});
User.hasOne(Address,{sourceKey: 'id'});
async function stuff() {
// Please note that when using async/await you lose the `bluebird` promise context
// and you fall back to native
const newUser = await User.create({
name: 'Johnny',
preferredName: 'John',
......
import { Promise } from 'sequelize';
let promise: Promise<number> = Promise.resolve(1);
promise.then((arg: number) => ({})).then((a: {}) => void 0);
promise = new Promise<number>(resolve => resolve());
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!