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

Commit 99f396c5 by Simon Schick Committed by Sushant

fix(types): add index hints (#10815)

1 parent 030e0fac
...@@ -3,6 +3,7 @@ import Deferrable = require('./lib/deferrable'); ...@@ -3,6 +3,7 @@ import Deferrable = require('./lib/deferrable');
import Op = require('./lib/operators'); import Op = require('./lib/operators');
import QueryTypes = require('./lib/query-types'); import QueryTypes = require('./lib/query-types');
import TableHints = require('./lib/table-hints'); import TableHints = require('./lib/table-hints');
import IndexHints = require('./lib/index-hints');
import Utils = require('./lib/utils'); import Utils = require('./lib/utils');
export * from './lib/sequelize'; export * from './lib/sequelize';
...@@ -15,5 +16,5 @@ export * from './lib/errors'; ...@@ -15,5 +16,5 @@ export * from './lib/errors';
export { BaseError as Error } from './lib/errors'; export { BaseError as Error } from './lib/errors';
export { useInflection } from './lib/utils'; export { useInflection } from './lib/utils';
export { Promise } from './lib/promise'; export { Promise } from './lib/promise';
export { Utils, QueryTypes, Op, TableHints, DataTypes, Deferrable }; export { Utils, QueryTypes, Op, TableHints, IndexHints, DataTypes, Deferrable };
export { Validator as validator } from './lib/utils/validator-extras'; export { Validator as validator } from './lib/utils/validator-extras';
/**
* Available index hints to be used for querying data in mysql for index hints.
*/
declare enum IndexHints {
USE = 'USE',
FORCE = 'FORCE',
IGNORE = 'IGNORE'
}
export = IndexHints;
...@@ -20,6 +20,7 @@ import { QueryOptions } from './query-interface'; ...@@ -20,6 +20,7 @@ import { QueryOptions } from './query-interface';
import { Config, Options, Sequelize, SyncOptions } from './sequelize'; import { Config, Options, Sequelize, SyncOptions } from './sequelize';
import { Transaction } from './transaction'; import { Transaction } from './transaction';
import { Col, Fn, Literal, Where } from './utils'; import { Col, Fn, Literal, Where } from './utils';
import { IndexHints } from '..';
export interface Logging { export interface Logging {
/** /**
...@@ -432,12 +433,24 @@ export type FindAttributeOptions = ...@@ -432,12 +433,24 @@ export type FindAttributeOptions =
include: (string | ProjectionAlias)[]; include: (string | ProjectionAlias)[];
}; };
export interface IndexHint {
type: IndexHints;
value: string[];
}
export interface IndexHintable {
/**
* MySQL only.
*/
indexHints?: IndexHint[];
}
/** /**
* Options that are passed to any model creating a SELECT query * Options that are passed to any model creating a SELECT query
* *
* A hash of options to describe the scope of the search * A hash of options to describe the scope of the search
*/ */
export interface FindOptions extends QueryOptions, Filterable, Projectable, Paranoid { export interface FindOptions extends QueryOptions, Filterable, Projectable, Paranoid, IndexHintable {
/** /**
* A list of associations to eagerly load using a left join. Supported is either * A list of associations to eagerly load using a left join. Supported is either
* `{ include: [ Model1, Model2, ...]}`, `{ include: [{ model: Model1, as: 'Alias' }]}` or * `{ include: [ Model1, Model2, ...]}`, `{ include: [{ model: Model1, as: 'Alias' }]}` or
......
import { User } from 'models/User';
import { IndexHints } from '..';
User.findAll({
indexHints: [{
type: IndexHints.FORCE,
value: ['some_index'],
}],
})
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!