UNPKG

50.5 kBTypeScriptView Raw
1import * as DataTypes from './data-types';
2import * as Deferrable from './deferrable';
3import { HookReturn, Hooks, SequelizeHooks } from './hooks';
4import { ValidationOptions } from './instance-validator';
5import {
6 AndOperator,
7 BulkCreateOptions,
8 CreateOptions,
9 DestroyOptions,
10 DropOptions,
11 FindOptions,
12 InstanceDestroyOptions,
13 Logging,
14 Model,
15 ModelAttributeColumnOptions,
16 ModelAttributes,
17 ModelOptions,
18 OrOperator,
19 UpdateOptions,
20 WhereAttributeHash,
21 WhereOperators,
22 ModelCtor,
23} from './model';
24import { ModelManager } from './model-manager';
25import * as Op from './operators';
26import { Promise } from './promise';
27import { QueryInterface, QueryOptions, QueryOptionsWithModel, QueryOptionsWithType } from './query-interface';
28import QueryTypes = require('./query-types');
29import { Transaction, TransactionOptions } from './transaction';
30import { Cast, Col, Fn, Json, Literal, Where } from './utils';
31// tslint:disable-next-line:no-duplicate-imports
32import * as Utils from './utils';
33import { validator } from './utils/validator-extras';
34import { ConnectionManager } from './connection-manager';
35
36/**
37 * Sync Options
38 */
39export interface SyncOptions extends Logging {
40 /**
41 * If force is true, each DAO will do DROP TABLE IF EXISTS ..., before it tries to create its own table
42 */
43 force?: boolean;
44
45 /**
46 * If alter is true, each DAO will do ALTER TABLE ... CHANGE ...
47 * Alters tables to fit models. Not recommended for production use. Deletes data in columns that were removed or had their type changed in the model.
48 */
49 alter?: boolean;
50
51 /**
52 * Match a regex against the database name before syncing, a safety check for cases where force: true is
53 * used in tests but not live code
54 */
55 match?: RegExp;
56
57 /**
58 * The schema that the tables should be created in. This can be overridden for each table in sequelize.define
59 */
60 schema?: string;
61
62 /**
63 * An optional parameter to specify the schema search_path (Postgres only)
64 */
65 searchPath?: string;
66
67 /**
68 * If hooks is true then beforeSync, afterSync, beforeBulkSync, afterBulkSync hooks will be called
69 */
70 hooks?: boolean;
71}
72
73export interface DefaultSetOptions {}
74
75/**
76 * Connection Pool options
77 */
78export interface PoolOptions {
79 /**
80 * Maximum number of connections in pool. Default is 5
81 */
82 max?: number;
83
84 /**
85 * Minimum number of connections in pool. Default is 0
86 */
87 min?: number;
88
89 /**
90 * The maximum time, in milliseconds, that a connection can be idle before being released
91 */
92 idle?: number;
93
94 /**
95 * The maximum time, in milliseconds, that pool will try to get connection before throwing error
96 */
97 acquire?: number;
98
99 /**
100 * The time interval, in milliseconds, after which sequelize-pool will remove idle connections.
101 */
102 evict?: number;
103
104 /**
105 * A function that validates a connection. Called with client. The default function checks that client is an
106 * object, and that its state is not disconnected
107 */
108 validate?(client?: unknown): boolean;
109}
110
111export interface ConnectionOptions {
112 host?: string;
113 port?: string | number;
114 username?: string;
115 password?: string;
116 database?: string;
117}
118
119/**
120 * Interface for replication Options in the sequelize constructor
121 */
122export interface ReplicationOptions {
123 read: ConnectionOptions[];
124
125 write: ConnectionOptions;
126}
127
128/**
129 * Used to map operators to their Symbol representations
130 */
131export interface OperatorsAliases {
132 [K: string]: symbol;
133}
134
135/**
136 * Final config options generated by sequelize.
137 */
138export interface Config {
139 readonly database: string;
140 readonly dialectModule?: object;
141 readonly host?: string;
142 readonly port?: string;
143 readonly username: string;
144 readonly password: string | null;
145 readonly pool?: {
146 readonly acquire: number;
147 readonly idle: number;
148 readonly max: number;
149 readonly min: number;
150 };
151 readonly protocol: 'tcp';
152 readonly native: boolean;
153 readonly ssl: boolean;
154 readonly replication: boolean;
155 readonly dialectModulePath: null | string;
156 readonly keepDefaultTimezone?: boolean;
157 readonly dialectOptions?: {
158 readonly charset?: string;
159 readonly timeout?: number;
160 };
161}
162
163export type Dialect = 'mysql' | 'postgres' | 'sqlite' | 'mariadb' | 'mssql' | 'mariadb';
164
165export interface RetryOptions {
166 match?: (RegExp | string | Function)[];
167 max?: number;
168}
169
170/**
171 * Options for the constructor of Sequelize main class
172 */
173export interface Options extends Logging {
174 /**
175 * The dialect of the database you are connecting to. One of mysql, postgres, sqlite, mariadb and mssql.
176 *
177 * @default 'mysql'
178 */
179 dialect?: Dialect;
180
181 /**
182 * If specified, will use the provided module as the dialect.
183 *
184 * @example
185 * `dialectModule: require('@myorg/tedious'),`
186 */
187 dialectModule?: object;
188
189
190 /**
191 * If specified, load the dialect library from this path. For example, if you want to use pg.js instead of
192 * pg when connecting to a pg database, you should specify 'pg.js' here
193 */
194 dialectModulePath?: string;
195
196 /**
197 * An object of additional options, which are passed directly to the connection library
198 */
199 dialectOptions?: object;
200
201 /**
202 * Only used by sqlite.
203 *
204 * @default ':memory:'
205 */
206 storage?: string;
207
208 /**
209 * The name of the database
210 */
211 database?: string;
212
213 /**
214 * The username which is used to authenticate against the database.
215 */
216 username?: string;
217
218 /**
219 * The password which is used to authenticate against the database.
220 */
221 password?: string;
222
223 /**
224 * The host of the relational database.
225 *
226 * @default 'localhost'
227 */
228 host?: string;
229
230 /**
231 * The port of the relational database.
232 */
233 port?: number;
234
235 /**
236 * A flag that defines if is used SSL.
237 */
238 ssl?: boolean;
239
240 /**
241 * The protocol of the relational database.
242 *
243 * @default 'tcp'
244 */
245 protocol?: string;
246
247 /**
248 * Default options for model definitions. See Model.init.
249 */
250 define?: ModelOptions;
251
252 /**
253 * Default options for sequelize.query
254 */
255 query?: QueryOptions;
256
257 /**
258 * Default options for sequelize.set
259 */
260 set?: DefaultSetOptions;
261
262 /**
263 * Default options for sequelize.sync
264 */
265 sync?: SyncOptions;
266
267 /**
268 * The timezone used when converting a date from the database into a JavaScript date. The timezone is also
269 * used to SET TIMEZONE when connecting to the server, to ensure that the result of NOW, CURRENT_TIMESTAMP
270 * and other time related functions have in the right timezone. For best cross platform performance use the
271 * format
272 * +/-HH:MM. Will also accept string versions of timezones used by moment.js (e.g. 'America/Los_Angeles');
273 * this is useful to capture daylight savings time changes.
274 *
275 * @default '+00:00'
276 */
277 timezone?: string;
278
279 /**
280 * A flag that defines if null values should be passed to SQL queries or not.
281 *
282 * @default false
283 */
284 omitNull?: boolean;
285
286 /**
287 * A flag that defines if native library shall be used or not. Currently only has an effect for postgres
288 *
289 * @default false
290 */
291 native?: boolean;
292
293 /**
294 * Use read / write replication. To enable replication, pass an object, with two properties, read and write.
295 * Write should be an object (a single server for handling writes), and read an array of object (several
296 * servers to handle reads). Each read/write server can have the following properties: `host`, `port`,
297 * `username`, `password`, `database`
298 *
299 * @default false
300 */
301 replication?: ReplicationOptions;
302
303 /**
304 * Connection pool options
305 */
306 pool?: PoolOptions;
307
308 /**
309 * Set to `false` to make table names and attributes case-insensitive on Postgres and skip double quoting of
310 * them.
311 *
312 * @default true
313 */
314 quoteIdentifiers?: boolean;
315
316 /**
317 * Set the default transaction isolation level. See `Sequelize.Transaction.ISOLATION_LEVELS` for possible
318 * options.
319 *
320 * @default 'REPEATABLE_READ'
321 */
322 isolationLevel?: string;
323
324 /**
325 * Run built in type validators on insert and update, e.g. validate that arguments passed to integer
326 * fields are integer-like.
327 *
328 * @default false
329 */
330 typeValidation?: boolean;
331
332 /**
333 * Sets available operator aliases.
334 * See (https://sequelize.org/master/manual/querying.html#operators) for more information.
335 * WARNING: Setting this to boolean value was deprecated and is no-op.
336 *
337 * @default all aliases
338 */
339 operatorsAliases?: OperatorsAliases;
340
341
342 /**
343 * The PostgreSQL `standard_conforming_strings` session parameter. Set to `false` to not set the option.
344 * WARNING: Setting this to false may expose vulnerabilities and is not recommended!
345 *
346 * @default true
347 */
348 standardConformingStrings?: boolean;
349
350 /**
351 * Sets global permanent hooks.
352 */
353 hooks?: Partial<SequelizeHooks>;
354
355 /**
356 * Set to `true` to automatically minify aliases generated by sequelize.
357 * Mostly useful to circumvent the POSTGRES alias limit of 64 characters.
358 *
359 * @default false
360 */
361 minifyAliases?: boolean;
362
363 /**
364 * Set to `true` to show bind patameters in log.
365 *
366 * @default false
367 */
368 logQueryParameters?: boolean;
369
370 retry?: RetryOptions;
371}
372
373export interface QueryOptionsTransactionRequired {}
374
375/**
376 * This is the main class, the entry point to sequelize. To use it, you just need to
377 * import sequelize:
378 *
379 * ```js
380 * const Sequelize = require('sequelize');
381 * ```
382 *
383 * In addition to sequelize, the connection library for the dialect you want to use
384 * should also be installed in your project. You don't need to import it however, as
385 * sequelize will take care of that.
386 */
387export class Sequelize extends Hooks {
388
389 // -------------------- Utilities ------------------------------------------------------------------------
390
391 /**
392 * Creates a object representing a database function. This can be used in search queries, both in where and
393 * order parts, and as default values in column definitions. If you want to refer to columns in your
394 * function, you should use `sequelize.col`, so that the columns are properly interpreted as columns and
395 * not a strings.
396 *
397 * Convert a user's username to upper case
398 * ```js
399 * instance.update({
400 * username: self.sequelize.fn('upper', self.sequelize.col('username'))
401 * })
402 * ```
403 * @param fn The function you want to call
404 * @param args All further arguments will be passed as arguments to the function
405 */
406 public static fn: typeof fn;
407
408 /**
409 * Creates a object representing a column in the DB. This is often useful in conjunction with
410 * `sequelize.fn`, since raw string arguments to fn will be escaped.
411 *
412 * @param col The name of the column
413 */
414 public static col: typeof col;
415
416 /**
417 * Creates a object representing a call to the cast function.
418 *
419 * @param val The value to cast
420 * @param type The type to cast it to
421 */
422 public static cast: typeof cast;
423
424 /**
425 * Creates a object representing a literal, i.e. something that will not be escaped.
426 *
427 * @param val
428 */
429 public static literal: typeof literal;
430
431 /**
432 * An AND query
433 *
434 * @param args Each argument will be joined by AND
435 */
436 public static and: typeof and;
437
438 /**
439 * An OR query
440 *
441 * @param args Each argument will be joined by OR
442 */
443 public static or: typeof or;
444
445 /**
446 * Creates an object representing nested where conditions for postgres's json data-type.
447 *
448 * @param conditionsOrPath A hash containing strings/numbers or other nested hash, a string using dot
449 * notation or a string using postgres json syntax.
450 * @param value An optional value to compare against. Produces a string of the form "<json path> =
451 * '<value>'".
452 */
453 public static json: typeof json;
454
455 /**
456 * A way of specifying attr = condition.
457 *
458 * The attr can either be an object taken from `Model.rawAttributes` (for example `Model.rawAttributes.id`
459 * or
460 * `Model.rawAttributes.name`). The attribute should be defined in your model definition. The attribute can
461 * also be an object from one of the sequelize utility functions (`sequelize.fn`, `sequelize.col` etc.)
462 *
463 * For string attributes, use the regular `{ where: { attr: something }}` syntax. If you don't want your
464 * string to be escaped, use `sequelize.literal`.
465 *
466 * @param attr The attribute, which can be either an attribute object from `Model.rawAttributes` or a
467 * sequelize object, for example an instance of `sequelize.fn`. For simple string attributes, use the
468 * POJO syntax
469 * @param comparator Comparator
470 * @param logic The condition. Can be both a simply type, or a further condition (`.or`, `.and`, `.literal`
471 * etc.)
472 */
473 public static where: typeof where;
474
475 /**
476 * A hook that is run before validation
477 *
478 * @param name
479 * @param fn A callback function that is called with instance, options
480 */
481 public static beforeValidate(name: string, fn: (instance: Model, options: ValidationOptions) => void): void;
482 public static beforeValidate(fn: (instance: Model, options: ValidationOptions) => void): void;
483
484 /**
485 * A hook that is run after validation
486 *
487 * @param name
488 * @param fn A callback function that is called with instance, options
489 */
490 public static afterValidate(name: string, fn: (instance: Model, options: ValidationOptions) => void): void;
491 public static afterValidate(fn: (instance: Model, options: ValidationOptions) => void): void;
492
493 /**
494 * A hook that is run before creating a single instance
495 *
496 * @param name
497 * @param fn A callback function that is called with attributes, options
498 */
499 public static beforeCreate(name: string, fn: (attributes: Model, options: CreateOptions) => void): void;
500 public static beforeCreate(fn: (attributes: Model, options: CreateOptions) => void): void;
501
502 /**
503 * A hook that is run after creating a single instance
504 *
505 * @param name
506 * @param fn A callback function that is called with attributes, options
507 */
508 public static afterCreate(name: string, fn: (attributes: Model, options: CreateOptions) => void): void;
509 public static afterCreate(fn: (attributes: Model, options: CreateOptions) => void): void;
510
511 /**
512 * A hook that is run before destroying a single instance
513 *
514 * @param name
515 * @param fn A callback function that is called with instance, options
516 */
517 public static beforeDestroy(name: string, fn: (instance: Model, options: InstanceDestroyOptions) => void): void;
518 public static beforeDestroy(fn: (instance: Model, options: InstanceDestroyOptions) => void): void;
519
520 /**
521 * A hook that is run after destroying a single instance
522 *
523 * @param name
524 * @param fn A callback function that is called with instance, options
525 */
526 public static afterDestroy(name: string, fn: (instance: Model, options: InstanceDestroyOptions) => void): void;
527 public static afterDestroy(fn: (instance: Model, options: InstanceDestroyOptions) => void): void;
528
529 /**
530 * A hook that is run before updating a single instance
531 *
532 * @param name
533 * @param fn A callback function that is called with instance, options
534 */
535 public static beforeUpdate(name: string, fn: (instance: Model, options: UpdateOptions) => void): void;
536 public static beforeUpdate(fn: (instance: Model, options: UpdateOptions) => void): void;
537
538 /**
539 * A hook that is run after updating a single instance
540 *
541 * @param name
542 * @param fn A callback function that is called with instance, options
543 */
544 public static afterUpdate(name: string, fn: (instance: Model, options: UpdateOptions) => void): void;
545 public static afterUpdate(fn: (instance: Model, options: UpdateOptions) => void): void;
546
547 /**
548 * A hook that is run before creating or updating a single instance, It proxies `beforeCreate` and `beforeUpdate`
549 *
550 * @param name
551 * @param fn A callback function that is called with instance, options
552 */
553 public static beforeSave(name: string, fn: (instance: Model, options: UpdateOptions | CreateOptions) => void): void;
554 public static beforeSave(fn: (instance: Model, options: UpdateOptions | CreateOptions) => void): void;
555
556 /**
557 * A hook that is run after creating or updating a single instance, It proxies `afterCreate` and `afterUpdate`
558 *
559 * @param name
560 * @param fn A callback function that is called with instance, options
561 */
562 public static afterSave(name: string, fn: (instance: Model, options: UpdateOptions | CreateOptions) => void): void;
563 public static afterSave(fn: (instance: Model, options: UpdateOptions | CreateOptions) => void): void;
564
565 /**
566 * A hook that is run before creating instances in bulk
567 *
568 * @param name
569 * @param fn A callback function that is called with instances, options
570 */
571 public static beforeBulkCreate(name: string, fn: (instances: Model[], options: BulkCreateOptions) => void): void;
572 public static beforeBulkCreate(fn: (instances: Model[], options: BulkCreateOptions) => void): void;
573
574 /**
575 * A hook that is run after creating instances in bulk
576 *
577 * @param name
578 * @param fn A callback function that is called with instances, options
579 */
580 public static afterBulkCreate(name: string, fn: (instances: Model[], options: BulkCreateOptions) => void): void;
581 public static afterBulkCreate(fn: (instances: Model[], options: BulkCreateOptions) => void): void;
582
583 /**
584 * A hook that is run before destroying instances in bulk
585 *
586 * @param name
587 * @param fn A callback function that is called with options
588 */
589 public static beforeBulkDestroy(name: string, fn: (options: BulkCreateOptions) => void): void;
590 public static beforeBulkDestroy(fn: (options: BulkCreateOptions) => void): void;
591
592 /**
593 * A hook that is run after destroying instances in bulk
594 *
595 * @param name
596 * @param fn A callback function that is called with options
597 */
598 public static afterBulkDestroy(name: string, fn: (options: DestroyOptions) => void): void;
599 public static afterBulkDestroy(fn: (options: DestroyOptions) => void): void;
600
601 /**
602 * A hook that is run after updating instances in bulk
603 *
604 * @param name
605 * @param fn A callback function that is called with options
606 */
607 public static beforeBulkUpdate(name: string, fn: (options: UpdateOptions) => void): void;
608 public static beforeBulkUpdate(fn: (options: UpdateOptions) => void): void;
609
610 /**
611 * A hook that is run after updating instances in bulk
612 *
613 * @param name
614 * @param fn A callback function that is called with options
615 */
616 public static afterBulkUpdate(name: string, fn: (options: UpdateOptions) => void): void;
617 public static afterBulkUpdate(fn: (options: UpdateOptions) => void): void;
618
619 /**
620 * A hook that is run before a find (select) query
621 *
622 * @param name
623 * @param fn A callback function that is called with options
624 */
625 public static beforeFind(name: string, fn: (options: FindOptions) => void): void;
626 public static beforeFind(fn: (options: FindOptions) => void): void;
627
628 /**
629 * A hook that is run before a connection is established
630 *
631 * @param name
632 * @param fn A callback function that is called with options
633 */
634 public static beforeConnect(name: string, fn: (options: Config) => void): void;
635 public static beforeConnect(fn: (options: Config) => void): void;
636
637 /**
638 * A hook that is run after a connection is established
639 *
640 * @param name
641 * @param fn A callback function that is called with options
642 */
643 public static afterConnect(name: string, fn: (connection: unknown, options: Config) => void): void;
644 public static afterConnect(fn: (connection: unknown, options: Config) => void): void;
645
646 /**
647 * A hook that is run before a connection is released
648 *
649 * @param name
650 * @param fn A callback function that is called with options
651 */
652 public static beforeDisconnect(name: string, fn: (connection: unknown) => void): void;
653 public static beforeDisconnect(fn: (connection: unknown) => void): void;
654
655 /**
656 * A hook that is run after a connection is released
657 *
658 * @param name
659 * @param fn A callback function that is called with options
660 */
661 public static afterDisconnect(name: string, fn: (connection: unknown) => void): void;
662 public static afterDisconnect(fn: (connection: unknown) => void): void;
663
664 /**
665 * A hook that is run before a find (select) query, after any { include: {all: ...} } options are expanded
666 *
667 * @param name
668 * @param fn A callback function that is called with options
669 */
670 public static beforeFindAfterExpandIncludeAll(name: string, fn: (options: FindOptions) => void): void;
671 public static beforeFindAfterExpandIncludeAll(fn: (options: FindOptions) => void): void;
672
673 /**
674 * A hook that is run before a find (select) query, after all option parsing is complete
675 *
676 * @param name
677 * @param fn A callback function that is called with options
678 */
679 public static beforeFindAfterOptions(name: string, fn: (options: FindOptions) => void): void;
680 public static beforeFindAfterOptions(fn: (options: FindOptions) => void): void;
681
682 /**
683 * A hook that is run after a find (select) query
684 *
685 * @param name
686 * @param fn A callback function that is called with instance(s), options
687 */
688 public static afterFind(
689 name: string,
690 fn: (instancesOrInstance: Model[] | Model | null, options: FindOptions) => void
691 ): void;
692 public static afterFind(
693 fn: (instancesOrInstance: Model[] | Model | null, options: FindOptions) => void
694 ): void;
695
696 /**
697 * A hook that is run before a define call
698 *
699 * @param name
700 * @param fn A callback function that is called with attributes, options
701 */
702 public static beforeDefine<M extends Model>(
703 name: string,
704 fn: (attributes: ModelAttributes, options: ModelOptions<M>) => void
705 ): void;
706 public static beforeDefine<M extends Model>(
707 fn: (attributes: ModelAttributes, options: ModelOptions<M>) => void
708 ): void;
709
710 /**
711 * A hook that is run after a define call
712 *
713 * @param name
714 * @param fn A callback function that is called with factory
715 */
716 public static afterDefine(name: string, fn: (model: typeof Model) => void): void;
717 public static afterDefine(fn: (model: typeof Model) => void): void;
718
719 /**
720 * A hook that is run before Sequelize() call
721 *
722 * @param name
723 * @param fn A callback function that is called with config, options
724 */
725 public static beforeInit(name: string, fn: (config: Config, options: Options) => void): void;
726 public static beforeInit(fn: (config: Config, options: Options) => void): void;
727
728 /**
729 * A hook that is run after Sequelize() call
730 *
731 * @param name
732 * @param fn A callback function that is called with sequelize
733 */
734 public static afterInit(name: string, fn: (sequelize: Sequelize) => void): void;
735 public static afterInit(fn: (sequelize: Sequelize) => void): void;
736
737 /**
738 * A hook that is run before sequelize.sync call
739 * @param fn A callback function that is called with options passed to sequelize.sync
740 */
741 public static beforeBulkSync(name: string, fn: (options: SyncOptions) => HookReturn): void;
742 public static beforeBulkSync(fn: (options: SyncOptions) => HookReturn): void;
743
744 /**
745 * A hook that is run after sequelize.sync call
746 * @param fn A callback function that is called with options passed to sequelize.sync
747 */
748 public static afterBulkSync(name: string, fn: (options: SyncOptions) => HookReturn): void;
749 public static afterBulkSync(fn: (options: SyncOptions) => HookReturn): void;
750
751 /**
752 * A hook that is run before Model.sync call
753 * @param fn A callback function that is called with options passed to Model.sync
754 */
755 public static beforeSync(name: string, fn: (options: SyncOptions) => HookReturn): void;
756 public static beforeSync(fn: (options: SyncOptions) => HookReturn): void;
757
758 /**
759 * A hook that is run after Model.sync call
760 * @param fn A callback function that is called with options passed to Model.sync
761 */
762 public static afterSync(name: string, fn: (options: SyncOptions) => HookReturn): void;
763 public static afterSync(fn: (options: SyncOptions) => HookReturn): void;
764
765 /**
766 * Use CLS with Sequelize.
767 * CLS namespace provided is stored as `Sequelize._cls`
768 * and bluebird Promise is patched to use the namespace, using `cls-bluebird` module.
769 *
770 * @param namespace
771 */
772 public static useCLS(namespace: object): typeof Sequelize;
773
774 /**
775 * A reference to Sequelize constructor from sequelize. Useful for accessing DataTypes, Errors etc.
776 */
777 public Sequelize: typeof Sequelize;
778
779 /**
780 * Final config that is used by sequelize.
781 */
782 public readonly config: Config;
783
784 public readonly modelManager: ModelManager;
785
786 public readonly connectionManager: ConnectionManager;
787
788 /**
789 * Dictionary of all models linked with this instance.
790 */
791 public readonly models: {
792 [key: string]: ModelCtor<Model>;
793 };
794
795 /**
796 * Instantiate sequelize with name of database, username and password
797 *
798 * #### Example usage
799 *
800 * ```javascript
801 * // without password and options
802 * const sequelize = new Sequelize('database', 'username')
803 *
804 * // without options
805 * const sequelize = new Sequelize('database', 'username', 'password')
806 *
807 * // without password / with blank password
808 * const sequelize = new Sequelize('database', 'username', null, {})
809 *
810 * // with password and options
811 * const sequelize = new Sequelize('my_database', 'john', 'doe', {})
812 *
813 * // with uri (see below)
814 * const sequelize = new Sequelize('mysql://localhost:3306/database', {})
815 * ```
816 *
817 * @param database The name of the database
818 * @param username The username which is used to authenticate against the
819 * database.
820 * @param password The password which is used to authenticate against the
821 * database.
822 * @param options An object with options.
823 */
824 constructor(database: string, username: string, password?: string, options?: Options);
825 constructor(database: string, username: string, options?: Options);
826 constructor(options?: Options);
827
828 /**
829 * Instantiate sequelize with an URI
830 * @param uri A full database URI
831 * @param options See above for possible options
832 */
833 constructor(uri: string, options?: Options);
834
835 /**
836 * A hook that is run before validation
837 *
838 * @param name
839 * @param fn A callback function that is called with instance, options
840 */
841 public beforeValidate(name: string, fn: (instance: Model, options: ValidationOptions) => void): void;
842 public beforeValidate(fn: (instance: Model, options: ValidationOptions) => void): void;
843
844 /**
845 * A hook that is run after validation
846 *
847 * @param name
848 * @param fn A callback function that is called with instance, options
849 */
850 public afterValidate(name: string, fn: (instance: Model, options: ValidationOptions) => void): void;
851 public afterValidate(fn: (instance: Model, options: ValidationOptions) => void): void;
852
853 /**
854 * A hook that is run before creating a single instance
855 *
856 * @param name
857 * @param fn A callback function that is called with attributes, options
858 */
859 public beforeCreate(name: string, fn: (attributes: Model, options: CreateOptions) => void): void;
860 public beforeCreate(fn: (attributes: Model, options: CreateOptions) => void): void;
861
862 /**
863 * A hook that is run after creating a single instance
864 *
865 * @param name
866 * @param fn A callback function that is called with attributes, options
867 */
868 public afterCreate(name: string, fn: (attributes: Model, options: CreateOptions) => void): void;
869 public afterCreate(fn: (attributes: Model, options: CreateOptions) => void): void;
870
871 /**
872 * A hook that is run before destroying a single instance
873 *
874 * @param name
875 * @param fn A callback function that is called with instance, options
876 */
877 public beforeDestroy(name: string, fn: (instance: Model, options: InstanceDestroyOptions) => void): void;
878 public beforeDestroy(fn: (instance: Model, options: InstanceDestroyOptions) => void): void;
879
880 /**
881 * A hook that is run after destroying a single instance
882 *
883 * @param name
884 * @param fn A callback function that is called with instance, options
885 */
886 public afterDestroy(name: string, fn: (instance: Model, options: InstanceDestroyOptions) => void): void;
887 public afterDestroy(fn: (instance: Model, options: InstanceDestroyOptions) => void): void;
888
889 /**
890 * A hook that is run before updating a single instance
891 *
892 * @param name
893 * @param fn A callback function that is called with instance, options
894 */
895 public beforeUpdate(name: string, fn: (instance: Model, options: UpdateOptions) => void): void;
896 public beforeUpdate(fn: (instance: Model, options: UpdateOptions) => void): void;
897
898 /**
899 * A hook that is run after updating a single instance
900 *
901 * @param name
902 * @param fn A callback function that is called with instance, options
903 */
904 public afterUpdate(name: string, fn: (instance: Model, options: UpdateOptions) => void): void;
905 public afterUpdate(fn: (instance: Model, options: UpdateOptions) => void): void;
906
907 /**
908 * A hook that is run before creating instances in bulk
909 *
910 * @param name
911 * @param fn A callback function that is called with instances, options
912 */
913 public beforeBulkCreate(name: string, fn: (instances: Model[], options: BulkCreateOptions) => void): void;
914 public beforeBulkCreate(fn: (instances: Model[], options: BulkCreateOptions) => void): void;
915
916 /**
917 * A hook that is run after creating instances in bulk
918 *
919 * @param name
920 * @param fn A callback function that is called with instances, options
921 */
922 public afterBulkCreate(name: string, fn: (instances: Model[], options: BulkCreateOptions) => void): void;
923 public afterBulkCreate(fn: (instances: Model[], options: BulkCreateOptions) => void): void;
924
925 /**
926 * A hook that is run before destroying instances in bulk
927 *
928 * @param name
929 * @param fn A callback function that is called with options
930 */
931 public beforeBulkDestroy(name: string, fn: (options: BulkCreateOptions) => void): void;
932 public beforeBulkDestroy(fn: (options: BulkCreateOptions) => void): void;
933
934 /**
935 * A hook that is run after destroying instances in bulk
936 *
937 * @param name
938 * @param fn A callback function that is called with options
939 */
940 public afterBulkDestroy(name: string, fn: (options: DestroyOptions) => void): void;
941 public afterBulkDestroy(fn: (options: DestroyOptions) => void): void;
942
943 /**
944 * A hook that is run after updating instances in bulk
945 *
946 * @param name
947 * @param fn A callback function that is called with options
948 */
949 public beforeBulkUpdate(name: string, fn: (options: UpdateOptions) => void): void;
950 public beforeBulkUpdate(fn: (options: UpdateOptions) => void): void;
951
952 /**
953 * A hook that is run after updating instances in bulk
954 *
955 * @param name
956 * @param fn A callback function that is called with options
957 */
958 public afterBulkUpdate(name: string, fn: (options: UpdateOptions) => void): void;
959 public afterBulkUpdate(fn: (options: UpdateOptions) => void): void;
960
961 /**
962 * A hook that is run before a find (select) query
963 *
964 * @param name
965 * @param fn A callback function that is called with options
966 */
967 public beforeFind(name: string, fn: (options: FindOptions) => void): void;
968 public beforeFind(fn: (options: FindOptions) => void): void;
969
970 /**
971 * A hook that is run before a find (select) query, after any { include: {all: ...} } options are expanded
972 *
973 * @param name
974 * @param fn A callback function that is called with options
975 */
976 public beforeFindAfterExpandIncludeAll(name: string, fn: (options: FindOptions) => void): void;
977 public beforeFindAfterExpandIncludeAll(fn: (options: FindOptions) => void): void;
978
979 /**
980 * A hook that is run before a find (select) query, after all option parsing is complete
981 *
982 * @param name
983 * @param fn A callback function that is called with options
984 */
985 public beforeFindAfterOptions(name: string, fn: (options: FindOptions) => void): void;
986 public beforeFindAfterOptions(fn: (options: FindOptions) => void): void;
987
988 /**
989 * A hook that is run after a find (select) query
990 *
991 * @param name
992 * @param fn A callback function that is called with instance(s), options
993 */
994 public afterFind(
995 name: string,
996 fn: (instancesOrInstance: Model[] | Model | null, options: FindOptions) => void
997 ): void;
998 public afterFind(fn: (instancesOrInstance: Model[] | Model | null, options: FindOptions) => void): void;
999
1000 /**
1001 * A hook that is run before a define call
1002 *
1003 * @param name
1004 * @param fn A callback function that is called with attributes, options
1005 */
1006 public beforeDefine(name: string, fn: (attributes: ModelAttributes, options: ModelOptions) => void): void;
1007 public beforeDefine(fn: (attributes: ModelAttributes, options: ModelOptions) => void): void;
1008
1009 /**
1010 * A hook that is run after a define call
1011 *
1012 * @param name
1013 * @param fn A callback function that is called with factory
1014 */
1015 public afterDefine(name: string, fn: (model: typeof Model) => void): void;
1016 public afterDefine(fn: (model: typeof Model) => void): void;
1017
1018 /**
1019 * A hook that is run before Sequelize() call
1020 *
1021 * @param name
1022 * @param fn A callback function that is called with config, options
1023 */
1024 public beforeInit(name: string, fn: (config: Config, options: Options) => void): void;
1025 public beforeInit(fn: (config: Config, options: Options) => void): void;
1026
1027 /**
1028 * A hook that is run after Sequelize() call
1029 *
1030 * @param name
1031 * @param fn A callback function that is called with sequelize
1032 */
1033 public afterInit(name: string, fn: (sequelize: Sequelize) => void): void;
1034 public afterInit(fn: (sequelize: Sequelize) => void): void;
1035
1036 /**
1037 * A hook that is run before sequelize.sync call
1038 * @param fn A callback function that is called with options passed to sequelize.sync
1039 */
1040 public beforeBulkSync(name: string, fn: (options: SyncOptions) => HookReturn): void;
1041 public beforeBulkSync(fn: (options: SyncOptions) => HookReturn): void;
1042
1043 /**
1044 * A hook that is run after sequelize.sync call
1045 * @param fn A callback function that is called with options passed to sequelize.sync
1046 */
1047 public afterBulkSync(name: string, fn: (options: SyncOptions) => HookReturn): void;
1048 public afterBulkSync(fn: (options: SyncOptions) => HookReturn): void;
1049
1050 /**
1051 * A hook that is run before Model.sync call
1052 * @param fn A callback function that is called with options passed to Model.sync
1053 */
1054 public beforeSync(name: string, fn: (options: SyncOptions) => HookReturn): void;
1055 public beforeSync(fn: (options: SyncOptions) => HookReturn): void;
1056
1057 /**
1058 * A hook that is run after Model.sync call
1059 * @param fn A callback function that is called with options passed to Model.sync
1060 */
1061 public afterSync(name: string, fn: (options: SyncOptions) => HookReturn): void;
1062 public afterSync(fn: (options: SyncOptions) => HookReturn): void;
1063
1064 /**
1065 * Returns the specified dialect.
1066 */
1067 public getDialect(): string;
1068
1069 /**
1070 * Returns an instance of QueryInterface.
1071 */
1072 public getQueryInterface(): QueryInterface;
1073
1074 /**
1075 * Define a new model, representing a table in the DB.
1076 *
1077 * The table columns are defined by the hash that is given as the second argument. Each attribute of the
1078 * hash
1079 * represents a column. A short table definition might look like this:
1080 *
1081 * ```js
1082 * class MyModel extends Model {}
1083 * MyModel.init({
1084 * columnA: {
1085 * type: Sequelize.BOOLEAN,
1086 * validate: {
1087 * is: ["[a-z]",'i'], // will only allow letters
1088 * max: 23, // only allow values <= 23
1089 * isIn: {
1090 * args: [['en', 'zh']],
1091 * msg: "Must be English or Chinese"
1092 * }
1093 * },
1094 * field: 'column_a'
1095 * // Other attributes here
1096 * },
1097 * columnB: Sequelize.STRING,
1098 * columnC: 'MY VERY OWN COLUMN TYPE'
1099 * }, { sequelize })
1100 *
1101 * sequelize.models.modelName // The model will now be available in models under the name given to define
1102 * ```
1103 *
1104 * As shown above, column definitions can be either strings, a reference to one of the datatypes that are
1105 * predefined on the Sequelize constructor, or an object that allows you to specify both the type of the
1106 * column, and other attributes such as default values, foreign key constraints and custom setters and
1107 * getters.
1108 *
1109 * For a list of possible data types, see
1110 * https://sequelize.org/master/en/latest/docs/models-definition/#data-types
1111 *
1112 * For more about getters and setters, see
1113 * https://sequelize.org/master/en/latest/docs/models-definition/#getters-setters
1114 *
1115 * For more about instance and class methods, see
1116 * https://sequelize.org/master/en/latest/docs/models-definition/#expansion-of-models
1117 *
1118 * For more about validation, see
1119 * https://sequelize.org/master/en/latest/docs/models-definition/#validations
1120 *
1121 * @param modelName The name of the model. The model will be stored in `sequelize.models` under this name
1122 * @param attributes An object, where each attribute is a column of the table. Each column can be either a
1123 * DataType, a string or a type-description object, with the properties described below:
1124 * @param options These options are merged with the default define options provided to the Sequelize
1125 * constructor
1126 */
1127 public define(modelName: string, attributes: ModelAttributes, options?: ModelOptions): typeof Model;
1128
1129 /**
1130 * Fetch a Model which is already defined
1131 *
1132 * @param modelName The name of a model defined with Sequelize.define
1133 */
1134 public model(modelName: string): ModelCtor<Model>;
1135
1136 /**
1137 * Checks whether a model with the given name is defined
1138 *
1139 * @param modelName The name of a model defined with Sequelize.define
1140 */
1141 public isDefined(modelName: string): boolean;
1142
1143 /**
1144 * Imports a model defined in another file
1145 *
1146 * Imported models are cached, so multiple calls to import with the same path will not load the file
1147 * multiple times
1148 *
1149 * See https://github.com/sequelize/sequelize/blob/master/examples/using-multiple-model-files/Task.js for a
1150 * short example of how to define your models in separate files so that they can be imported by
1151 * sequelize.import
1152 *
1153 * @param path The path to the file that holds the model you want to import. If the part is relative, it
1154 * will be resolved relatively to the calling file
1155 *
1156 * @param defineFunction An optional function that provides model definitions. Useful if you do not
1157 * want to use the module root as the define function
1158 */
1159 public import<T extends typeof Model>(
1160 path: string,
1161 defineFunction?: (sequelize: Sequelize, dataTypes: typeof DataTypes) => T
1162 ): T;
1163
1164 /**
1165 * Execute a query on the DB, optionally bypassing all the Sequelize goodness.
1166 *
1167 * By default, the function will return two arguments: an array of results, and a metadata object,
1168 * containing number of affected rows etc. Use `.then(([...]))` to access the results.
1169 *
1170 * If you are running a type of query where you don't need the metadata, for example a `SELECT` query, you
1171 * can pass in a query type to make sequelize format the results:
1172 *
1173 * ```js
1174 * sequelize.query('SELECT...').then(([results, metadata]) {
1175 * // Raw query - use spread
1176 * });
1177 *
1178 * sequelize.query('SELECT...', { type: sequelize.QueryTypes.SELECT }).then(results => {
1179 * // SELECT query - use then
1180 * })
1181 * ```
1182 *
1183 * @param sql
1184 * @param options Query options
1185 */
1186 public query(sql: string | { query: string; values: unknown[] }, options: QueryOptionsWithType<QueryTypes.UPDATE>): Promise<[undefined, number]>;
1187 public query(sql: string | { query: string; values: unknown[] }, options: QueryOptionsWithType<QueryTypes.BULKUPDATE>): Promise<number>;
1188 public query(sql: string | { query: string; values: unknown[] }, options: QueryOptionsWithType<QueryTypes.INSERT>): Promise<[number, number]>;
1189 public query(sql: string | { query: string; values: unknown[] }, options: QueryOptionsWithType<QueryTypes.UPSERT>): Promise<number>;
1190 public query(sql: string | { query: string; values: unknown[] }, options: QueryOptionsWithType<QueryTypes.DELETE>): Promise<void>;
1191 public query(sql: string | { query: string; values: unknown[] }, options: QueryOptionsWithType<QueryTypes.BULKDELETE>): Promise<number>;
1192 public query(sql: string | { query: string; values: unknown[] }, options: QueryOptionsWithType<QueryTypes.SHOWTABLES>): Promise<string[]>;
1193 public query(sql: string | { query: string; values: unknown[] }, options: QueryOptionsWithType<QueryTypes.DESCRIBE>): Promise<{
1194 [key: string]: {
1195 type: string;
1196 allowNull: boolean;
1197 defaultValue: string;
1198 primaryKey: boolean;
1199 autoIncrement: boolean;
1200 comment: string | null;
1201 }
1202 }>;
1203 public query<M extends Model>(
1204 sql: string | { query: string; values: unknown[] },
1205 options: QueryOptionsWithModel
1206 ): Promise<M[]>;
1207 public query<T extends object>(sql: string | { query: string; values: unknown[] }, options: QueryOptionsWithType<QueryTypes.SELECT> & { plain: true }): Promise<T>;
1208 public query<T extends object>(sql: string | { query: string; values: unknown[] }, options: QueryOptionsWithType<QueryTypes.SELECT>): Promise<T[]>;
1209 public query(sql: string | { query: string; values: unknown[] }, options: (QueryOptions | QueryOptionsWithType<QueryTypes.RAW>) & { plain: true }): Promise<{ [key: string]: unknown }>;
1210 public query(sql: string | { query: string; values: unknown[] }, options?: QueryOptions | QueryOptionsWithType<QueryTypes.RAW>): Promise<[unknown[], unknown]>;
1211
1212 /**
1213 * Get the fn for random based on the dialect
1214 */
1215 public random(): Fn;
1216
1217 /**
1218 * Execute a query which would set an environment or user variable. The variables are set per connection,
1219 * so this function needs a transaction.
1220 *
1221 * Only works for MySQL.
1222 *
1223 * @param variables object with multiple variables.
1224 * @param options Query options.
1225 */
1226 public set(variables: object, options: QueryOptionsTransactionRequired): Promise<unknown>;
1227
1228 /**
1229 * Escape value.
1230 *
1231 * @param value Value that needs to be escaped
1232 */
1233 public escape(value: string | number | Date): string;
1234
1235 /**
1236 * Create a new database schema.
1237 *
1238 * Note,that this is a schema in the
1239 * [postgres sense of the word](http://www.postgresql.org/docs/9.1/static/ddl-schemas.html),
1240 * not a database table. In mysql and sqlite, this command will do nothing.
1241 *
1242 * @param schema Name of the schema
1243 * @param options Options supplied
1244 */
1245 public createSchema(schema: string, options: Logging): Promise<unknown>;
1246
1247 /**
1248 * Show all defined schemas
1249 *
1250 * Note,that this is a schema in the
1251 * [postgres sense of the word](http://www.postgresql.org/docs/9.1/static/ddl-schemas.html),
1252 * not a database table. In mysql and sqlite, this will show all tables.
1253 *
1254 * @param options Options supplied
1255 */
1256 public showAllSchemas(options: Logging): Promise<object[]>;
1257
1258 /**
1259 * Drop a single schema
1260 *
1261 * Note,that this is a schema in the
1262 * [postgres sense of the word](http://www.postgresql.org/docs/9.1/static/ddl-schemas.html),
1263 * not a database table. In mysql and sqlite, this drop a table matching the schema name
1264 *
1265 * @param schema Name of the schema
1266 * @param options Options supplied
1267 */
1268 public dropSchema(schema: string, options: Logging): Promise<unknown[]>;
1269
1270 /**
1271 * Drop all schemas
1272 *
1273 * Note,that this is a schema in the
1274 * [postgres sense of the word](http://www.postgresql.org/docs/9.1/static/ddl-schemas.html),
1275 * not a database table. In mysql and sqlite, this is the equivalent of drop all tables.
1276 *
1277 * @param options Options supplied
1278 */
1279 public dropAllSchemas(options: Logging): Promise<unknown[]>;
1280
1281 /**
1282 * Sync all defined models to the DB.
1283 *
1284 * @param options Sync Options
1285 */
1286 public sync(options?: SyncOptions): Promise<this>;
1287
1288 /**
1289 * Truncate all tables defined through the sequelize models. This is done
1290 * by calling Model.truncate() on each model.
1291 *
1292 * @param [options] The options passed to Model.destroy in addition to truncate
1293 */
1294 public truncate(options?: DestroyOptions): Promise<unknown[]>;
1295
1296 /**
1297 * Drop all tables defined through this sequelize instance. This is done by calling Model.drop on each model
1298 *
1299 * @param options The options passed to each call to Model.drop
1300 */
1301 public drop(options?: DropOptions): Promise<unknown[]>;
1302
1303 /**
1304 * Test the connection by trying to authenticate
1305 *
1306 * @param options Query Options for authentication
1307 */
1308 public authenticate(options?: QueryOptions): Promise<void>;
1309 public validate(options?: QueryOptions): Promise<void>;
1310
1311 /**
1312 * Start a transaction. When using transactions, you should pass the transaction in the options argument
1313 * in order for the query to happen under that transaction
1314 *
1315 * ```js
1316 * sequelize.transaction().then(t => {
1317 * return User.findOne(..., { transaction: t}).then(user => {
1318 * return user.update(..., { transaction: t});
1319 * })
1320 * .then(t.commit.bind(t))
1321 * .catch(t.rollback.bind(t));
1322 * })
1323 * ```
1324 *
1325 * A syntax for automatically committing or rolling back based on the promise chain resolution is also
1326 * supported:
1327 *
1328 * ```js
1329 * sequelize.transaction(t => { // Note that we use a callback rather than a promise.then()
1330 * return User.findOne(..., { transaction: t}).then(user => {
1331 * return user.update(..., { transaction: t});
1332 * });
1333 * }).then(() => {
1334 * // Commited
1335 * }).catch(err => {
1336 * // Rolled back
1337 * console.error(err);
1338 * });
1339 * ```
1340 *
1341 * If you have [CLS](https://github.com/othiym23/node-continuation-local-storage) enabled, the transaction
1342 * will automatically be passed to any query that runs witin the callback. To enable CLS, add it do your
1343 * project, create a namespace and set it on the sequelize constructor:
1344 *
1345 * ```js
1346 * const cls = require('continuation-local-storage'),
1347 * ns = cls.createNamespace('....');
1348 * const Sequelize = require('sequelize');
1349 * Sequelize.cls = ns;
1350 * ```
1351 * Note, that CLS is enabled for all sequelize instances, and all instances will share the same namespace
1352 *
1353 * @param options Transaction Options
1354 * @param autoCallback Callback for the transaction
1355 */
1356 public transaction<T>(options: TransactionOptions, autoCallback: (t: Transaction) => PromiseLike<T>): Promise<T>;
1357 public transaction<T>(autoCallback: (t: Transaction) => PromiseLike<T>): Promise<T>;
1358 public transaction(options?: TransactionOptions): Promise<Transaction>;
1359
1360 /**
1361 * Close all connections used by this sequelize instance, and free all references so the instance can be
1362 * garbage collected.
1363 *
1364 * Normally this is done on process exit, so you only need to call this method if you are creating multiple
1365 * instances, and want to garbage collect some of them.
1366 */
1367 public close(): Promise<void>;
1368
1369 /**
1370 * Returns the database version
1371 */
1372 public databaseVersion(): Promise<string>;
1373}
1374
1375// Utilities
1376
1377/**
1378 * Creates a object representing a database function. This can be used in search queries, both in where and
1379 * order parts, and as default values in column definitions. If you want to refer to columns in your
1380 * function, you should use `sequelize.col`, so that the columns are properly interpreted as columns and
1381 * not a strings.
1382 *
1383 * Convert a user's username to upper case
1384 * ```js
1385 * instance.update({
1386 * username: self.sequelize.fn('upper', self.sequelize.col('username'))
1387 * })
1388 * ```
1389 * @param fn The function you want to call
1390 * @param args All further arguments will be passed as arguments to the function
1391 */
1392export function fn(fn: string, ...args: unknown[]): Fn;
1393
1394/**
1395 * Creates a object representing a column in the DB. This is often useful in conjunction with
1396 * `sequelize.fn`, since raw string arguments to fn will be escaped.
1397 *
1398 * @param col The name of the column
1399 */
1400export function col(col: string): Col;
1401
1402/**
1403 * Creates a object representing a call to the cast function.
1404 *
1405 * @param val The value to cast
1406 * @param type The type to cast it to
1407 */
1408export function cast(val: unknown, type: string): Cast;
1409
1410/**
1411 * Creates a object representing a literal, i.e. something that will not be escaped.
1412 *
1413 * @param val
1414 */
1415export function literal(val: string): Literal;
1416
1417/**
1418 * An AND query
1419 *
1420 * @param args Each argument will be joined by AND
1421 */
1422export function and(...args: (WhereOperators | WhereAttributeHash | Where)[]): AndOperator;
1423
1424/**
1425 * An OR query
1426 *
1427 * @param args Each argument will be joined by OR
1428 */
1429export function or(...args: (WhereOperators | WhereAttributeHash | Where)[]): OrOperator;
1430
1431/**
1432 * Creates an object representing nested where conditions for postgres's json data-type.
1433 *
1434 * @param conditionsOrPath A hash containing strings/numbers or other nested hash, a string using dot
1435 * notation or a string using postgres json syntax.
1436 * @param value An optional value to compare against. Produces a string of the form "<json path> =
1437 * '<value>'".
1438 */
1439export function json(conditionsOrPath: string | object, value?: string | number | boolean): Json;
1440
1441export type AttributeType = Fn | Col | Literal | ModelAttributeColumnOptions | string;
1442export type LogicType = Fn | Col | Literal | OrOperator | AndOperator | WhereOperators | string;
1443
1444/**
1445 * A way of specifying attr = condition.
1446 *
1447 * The attr can either be an object taken from `Model.rawAttributes` (for example `Model.rawAttributes.id`
1448 * or
1449 * `Model.rawAttributes.name`). The attribute should be defined in your model definition. The attribute can
1450 * also be an object from one of the sequelize utility functions (`sequelize.fn`, `sequelize.col` etc.)
1451 *
1452 * For string attributes, use the regular `{ where: { attr: something }}` syntax. If you don't want your
1453 * string to be escaped, use `sequelize.literal`.
1454 *
1455 * @param attr The attribute, which can be either an attribute object from `Model.rawAttributes` or a
1456 * sequelize object, for example an instance of `sequelize.fn`. For simple string attributes, use the
1457 * POJO syntax
1458 * @param comparator Comparator
1459 * @param logic The condition. Can be both a simply type, or a further condition (`.or`, `.and`, `.literal`
1460 * etc.)
1461 */
1462export function where(attr: AttributeType, comparator: string, logic: LogicType): Where;
1463export function where(attr: AttributeType, logic: LogicType): Where;
1464
1465export default Sequelize;
1466
\No newline at end of file