Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | import type { IncludeOption } from '../associations/include.ts';
import type { HooksOption } from '../hooks/hooks.ts';
import type { StandardSchemaV1 } from '../validation/standard-schema.ts';
import type { ModelValidatorFunction } from '../validation/types.ts';
import type { DefinitionOptions } from './model-definition.ts';
export type { ModelNameOptions } from './model-definition.ts';
import type { ScopeDefinition, ScopeOptions, WhereMergeStrategy } from './scope-registry.ts';
import type { Model } from './model.ts';
import type { RuntimeOwner } from './runtime.ts';
import type { MakeNullishOptional } from './types.ts';
export type {
AggregateOptions,
CountOptions,
CountWithOptions,
FindAndCountOptions,
FindAndCountResult,
GroupedCountResultItem,
FindOptions,
FindOrCreateOptions,
} from './find-options.ts';
export type {
AttributeAmounts,
CreateOptions,
IncrementOptions,
InstanceUpdateOptions,
InsertFromOptions,
InsertOptions,
SaveOptions,
UpsertOptions,
} from './write-options.ts';
export type {
BulkCreateOptions,
BulkHookOptions,
DestroyOptions,
InstanceDestroyOptions,
RestoreOptions,
UpdateOptions,
} from './bulk-options.ts';
export type { CopyFromOptions, CopyToFormatOptions, CopyToOptions } from './copy-options.ts';
/** Plain attribute values of a model. */
export type Values = Record<string, unknown>;
/** @internal Options object of an operation, passed to hooks (which may change it). */
export type MutableOptions = Record<string, unknown>;
/** Any model instance type. */
// oxlint-disable-next-line typescript/no-explicit-any -- Sequelize v6 compat: attribute types are unknown here
export type AnyModel = Model<any, any>;
/** Attribute types of model instance type `M`. */
export type Attributes<M extends AnyModel> = M['_attributes'];
/** Creation attribute types of model instance type `M`. */
export type CreationAttributes<M extends AnyModel> = MakeNullishOptional<M['_creationAttributes']>;
/** The static side of a class: its own members without the construct signature (Sequelize v6 `NonConstructor`). */
export type NonConstructor<T> = { [P in keyof T]: T[P] };
/** A model class whose instances are `M` (Sequelize v6 `ModelStatic`). */
export type ModelStatic<M extends AnyModel> = NonConstructor<typeof Model> & {
// oxlint-disable-next-line typescript/no-explicit-any -- accepts classes whose constructor takes typed values (v6 declares `new (): M`).
new (values?: any, options?: BuildOptions): M;
/** Instance prototype. */
prototype: M;
};
/** Schema-qualified table name returned by `getTableName`. */
export type QualifiedTableName = Readonly<{
/** Table name. */
tableName: string;
/** Table name (v6 alias of `tableName`). */
table: string;
/** Model name. */
name: string;
/** Schema name. */
schema: string;
/** Separator between schema and table. */
delimiter: string;
/** Quoted `"schema"."table"` reference. */
toString: () => string;
}>;
/**
* Options of `Model.init`: table-level options plus hooks, scopes and validation.
*
* Extends {@link DefinitionOptions}.
*
* @see {@link Model.init}
*
* @example
* ```ts
* User.init(
* { name: DataTypes.STRING, email: DataTypes.STRING },
* {
* sequelize,
* modelName: 'User',
* paranoid: true,
* defaultScope: { where: { active: true } },
* scopes: { admins: { where: { role: 'admin' } } },
* },
* );
* ```
*/
export type InitOptions = DefinitionOptions &
Readonly<{
/** Owning `Sequelize` instance. */
sequelize: RuntimeOwner;
/** Lifecycle hooks, by hook name. */
hooks?: HooksOption;
/** Scope applied to every query unless `unscoped()` / `scope()` is used. */
defaultScope?: ScopeOptions;
/** Named scopes: options or functions returning options. */
scopes?: Readonly<Record<string, ScopeDefinition>>;
/** How `where` of merged scopes combine: `'overwrite'` replaces same keys, `'and'` joins them with `Op.and`.
* @defaultValue 'overwrite' */
whereMergeStrategy?: WhereMergeStrategy;
/** Model-level validators; throw to fail. */
validate?: Readonly<Record<string, ModelValidatorFunction>>;
/**
* Standard Schema (zod, valibot, arktype) validating all attribute values. postgrelize extension; `schema` keeps its v6 meaning (PostgreSQL schema).
* @postgrelize
*/
validationSchema?: StandardSchemaV1;
}>;
/**
* Options of `Model.build` (and the model constructor).
*
* @see {@link Model.build}
*
* @example
* ```ts
* const opts: BuildOptions = { isNewRecord: false, raw: true };
* const user = User.build({ id: 1, name: 'Ann' }, opts);
* ```
*/
export type BuildOptions = Readonly<{
/** Whether the instance represents a row that does not exist yet; `save()` inserts when true, updates when false.
* @defaultValue true */
isNewRecord?: boolean;
/** Set values without setters and without change tracking.
* @defaultValue false */
raw?: boolean;
/** Build associated instances from nested values (Sequelize v6 nested creation). */
include?: IncludeOption;
}>;
|