postgrelize 0.0.0-stage → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +289 -0
- package/LICENSE +21 -0
- package/README.md +131 -2
- package/dist/associations/alias-minifier.d.ts +43 -0
- package/dist/associations/association-accessors.d.ts +21 -0
- package/dist/associations/association-key-types.d.ts +44 -0
- package/dist/associations/association-keys.d.ts +98 -0
- package/dist/associations/association-lookup.d.ts +26 -0
- package/dist/associations/association-shape.d.ts +25 -0
- package/dist/associations/association.d.ts +95 -0
- package/dist/associations/belongs-to-many.d.ts +86 -0
- package/dist/associations/belongs-to.d.ts +45 -0
- package/dist/associations/has-many.d.ts +79 -0
- package/dist/associations/has-one.d.ts +44 -0
- package/dist/associations/include-assembler.d.ts +21 -0
- package/dist/associations/include-columns.d.ts +24 -0
- package/dist/associations/include-joins.d.ts +17 -0
- package/dist/associations/include-loader.d.ts +48 -0
- package/dist/associations/include-order.d.ts +22 -0
- package/dist/associations/include-query-builder.d.ts +54 -0
- package/dist/associations/include-resolver.d.ts +29 -0
- package/dist/associations/include-rows.d.ts +47 -0
- package/dist/associations/include-sub-query.d.ts +35 -0
- package/dist/associations/include.d.ts +112 -0
- package/dist/associations/junction-keys.d.ts +23 -0
- package/dist/associations/nested-creator.d.ts +44 -0
- package/dist/associations/nested-saver.d.ts +30 -0
- package/dist/associations/owner-keys.d.ts +34 -0
- package/dist/associations/separate-include-loader.d.ts +24 -0
- package/dist/associations/types.d.ts +139 -0
- package/dist/connection/after-connect-hook.d.ts +24 -0
- package/dist/connection/connect-hooks.d.ts +26 -0
- package/dist/connection/connection-config.d.ts +33 -0
- package/dist/connection/connection-manager.d.ts +65 -0
- package/dist/connection/connection-types.d.ts +21 -0
- package/dist/connection/copy-from-stdin.d.ts +52 -0
- package/dist/connection/copy-runner.d.ts +30 -0
- package/dist/connection/copy-to-stdout.d.ts +49 -0
- package/dist/connection/copy.d.ts +22 -0
- package/dist/connection/notifications.d.ts +28 -0
- package/dist/connection/options.d.ts +165 -0
- package/dist/connection/query-logger.d.ts +41 -0
- package/dist/connection/replica-router.d.ts +20 -0
- package/dist/connection/statement-cache.d.ts +36 -0
- package/dist/connection/statement-timeout.d.ts +22 -0
- package/dist/data-types/abstract-data-type.d.ts +58 -0
- package/dist/data-types/array-literal-parser.d.ts +17 -0
- package/dist/data-types/array-type.d.ts +18 -0
- package/dist/data-types/bit-type.d.ts +14 -0
- package/dist/data-types/blob-type.d.ts +12 -0
- package/dist/data-types/char-type.d.ts +12 -0
- package/dist/data-types/composite-fields.d.ts +26 -0
- package/dist/data-types/composite-type.d.ts +32 -0
- package/dist/data-types/data-types.d.ts +176 -0
- package/dist/data-types/date-type.d.ts +14 -0
- package/dist/data-types/decimal-type.d.ts +13 -0
- package/dist/data-types/default-value-generator.d.ts +15 -0
- package/dist/data-types/enum-type.d.ts +19 -0
- package/dist/data-types/ewkb-reader.d.ts +18 -0
- package/dist/data-types/ewkb-writer.d.ts +17 -0
- package/dist/data-types/float-type.d.ts +12 -0
- package/dist/data-types/geometric-text.d.ts +65 -0
- package/dist/data-types/geometric-type.d.ts +46 -0
- package/dist/data-types/hstore-type.d.ts +16 -0
- package/dist/data-types/integer-type.d.ts +24 -0
- package/dist/data-types/json-type.d.ts +16 -0
- package/dist/data-types/multirange-type.d.ts +19 -0
- package/dist/data-types/range-type.d.ts +28 -0
- package/dist/data-types/record-text.d.ts +29 -0
- package/dist/data-types/scalar-type.d.ts +13 -0
- package/dist/data-types/spatial-type.d.ts +20 -0
- package/dist/data-types/string-type.d.ts +12 -0
- package/dist/data-types/text-type.d.ts +12 -0
- package/dist/data-types/timestamp-type.d.ts +15 -0
- package/dist/data-types/virtual-type.d.ts +15 -0
- package/dist/data-types/wall-clock.d.ts +14 -0
- package/dist/ddl/column-ddl.d.ts +73 -0
- package/dist/ddl/constraint-ddl.d.ts +30 -0
- package/dist/ddl/ddl-generator.d.ts +181 -0
- package/dist/ddl/ddl-guards.d.ts +60 -0
- package/dist/ddl/ddl-types.d.ts +204 -0
- package/dist/ddl/enum-ddl.d.ts +42 -0
- package/dist/ddl/extension-ddl.d.ts +57 -0
- package/dist/ddl/function-ddl.d.ts +98 -0
- package/dist/ddl/index-ddl.d.ts +29 -0
- package/dist/ddl/index-element-ddl.d.ts +19 -0
- package/dist/ddl/partition-ddl.d.ts +88 -0
- package/dist/ddl/partition-types.d.ts +94 -0
- package/dist/ddl/policy-ddl.d.ts +137 -0
- package/dist/ddl/routine-guards.d.ts +63 -0
- package/dist/ddl/sequence-ddl.d.ts +103 -0
- package/dist/ddl/sql-literal.d.ts +61 -0
- package/dist/ddl/table-ddl.d.ts +35 -0
- package/dist/ddl/trigger-ddl.d.ts +81 -0
- package/dist/ddl/view-ddl.d.ts +122 -0
- package/dist/decorators/association-applier.d.ts +18 -0
- package/dist/decorators/association-decorators.d.ts +72 -0
- package/dist/decorators/column-decorators.d.ts +147 -0
- package/dist/decorators/decorator-factory.d.ts +45 -0
- package/dist/decorators/decorator-signature.d.ts +26 -0
- package/dist/decorators/decorator-types.d.ts +24 -0
- package/dist/decorators/foreign-key-decorator.d.ts +21 -0
- package/dist/decorators/hook-decorators.d.ts +393 -0
- package/dist/decorators/init-arguments.d.ts +29 -0
- package/dist/decorators/model-decorators.d.ts +18 -0
- package/dist/decorators/model-metadata.d.ts +70 -0
- package/dist/decorators/table-decorators.d.ts +43 -0
- package/dist/decorators/timestamp-decorators.d.ts +38 -0
- package/dist/errors/base-error.d.ts +40 -0
- package/dist/errors/connection-errors.d.ts +152 -0
- package/dist/errors/database-errors.d.ts +186 -0
- package/dist/errors/errors.d.ts +5 -0
- package/dist/errors/map-pg-error.d.ts +27 -0
- package/dist/errors/misc-errors.d.ts +232 -0
- package/dist/errors/validation-errors.d.ts +141 -0
- package/dist/exports-associations.d.ts +6 -0
- package/dist/exports-core.d.ts +95 -0
- package/dist/exports-decorators.d.ts +8 -0
- package/dist/exports-errors.d.ts +2 -0
- package/dist/exports-model.d.ts +21 -0
- package/dist/exports-schema.d.ts +19 -0
- package/dist/expressions/call-expressions.d.ts +54 -0
- package/dist/expressions/condition-expressions.d.ts +51 -0
- package/dist/expressions/expression.d.ts +52 -0
- package/dist/expressions/jsonpath-helpers.d.ts +37 -0
- package/dist/expressions/logic.d.ts +25 -0
- package/dist/expressions/methods.d.ts +188 -0
- package/dist/expressions/op.d.ts +182 -0
- package/dist/expressions/query-expressions.d.ts +110 -0
- package/dist/expressions/row-expressions.d.ts +35 -0
- package/dist/expressions/search-helpers.d.ts +138 -0
- package/dist/expressions/trigram-helpers.d.ts +40 -0
- package/dist/hooks/hooks.d.ts +125 -0
- package/dist/index.cjs +21864 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +21688 -0
- package/dist/index.js.map +1 -0
- package/dist/model/attribute-columns.d.ts +85 -0
- package/dist/model/attribute-normalizer.d.ts +42 -0
- package/dist/model/attribute-options.d.ts +121 -0
- package/dist/model/bulk-insert-builder.d.ts +24 -0
- package/dist/model/bulk-options.d.ts +173 -0
- package/dist/model/copy-options.d.ts +51 -0
- package/dist/model/cte-builder.d.ts +134 -0
- package/dist/model/definition-normalizer.d.ts +26 -0
- package/dist/model/delete-query-builder.d.ts +42 -0
- package/dist/model/find-options.d.ts +144 -0
- package/dist/model/find-query-builder.d.ts +38 -0
- package/dist/model/inflector.d.ts +28 -0
- package/dist/model/insert-query-builder.d.ts +41 -0
- package/dist/model/instance-destroyer.d.ts +44 -0
- package/dist/model/instance-lifecycle-services.d.ts +61 -0
- package/dist/model/instance-lifecycle.d.ts +128 -0
- package/dist/model/instance-saver.d.ts +25 -0
- package/dist/model/instance-state.d.ts +48 -0
- package/dist/model/instance-validation.d.ts +35 -0
- package/dist/model/instance-values.d.ts +88 -0
- package/dist/model/instance-writer.d.ts +59 -0
- package/dist/model/join-source-builder.d.ts +25 -0
- package/dist/model/lateral-keys-builder.d.ts +25 -0
- package/dist/model/merge-action-builder.d.ts +31 -0
- package/dist/model/merge-options.d.ts +72 -0
- package/dist/model/merge-query-builder.d.ts +29 -0
- package/dist/model/merge-source-builder.d.ts +22 -0
- package/dist/model/mixins/model-aggregates.d.ts +69 -0
- package/dist/model/mixins/model-associations.d.ts +113 -0
- package/dist/model/mixins/model-constructor.d.ts +7 -0
- package/dist/model/mixins/model-finders.d.ts +140 -0
- package/dist/model/mixins/model-hooks.d.ts +142 -0
- package/dist/model/mixins/model-postgres.d.ts +198 -0
- package/dist/model/mixins/model-schema-binding.d.ts +36 -0
- package/dist/model/mixins/model-schema.d.ts +100 -0
- package/dist/model/mixins/model-scopes.d.ts +57 -0
- package/dist/model/mixins/model-writers.d.ts +175 -0
- package/dist/model/mixins/named-hooks.d.ts +28 -0
- package/dist/model/model-accessors.d.ts +22 -0
- package/dist/model/model-base.d.ts +83 -0
- package/dist/model/model-definition.d.ts +130 -0
- package/dist/model/model-instance-persistence.d.ts +132 -0
- package/dist/model/model-instance-values.d.ts +197 -0
- package/dist/model/model-operations.d.ts +22 -0
- package/dist/model/model-registry.d.ts +152 -0
- package/dist/model/model-services.d.ts +46 -0
- package/dist/model/model-state.d.ts +68 -0
- package/dist/model/model-values.d.ts +86 -0
- package/dist/model/model.d.ts +629 -0
- package/dist/model/on-conflict-builder.d.ts +111 -0
- package/dist/model/operations/bulk-create-operation.d.ts +40 -0
- package/dist/model/operations/copy-from-source.d.ts +51 -0
- package/dist/model/operations/copy-operation.d.ts +54 -0
- package/dist/model/operations/count-operation.d.ts +52 -0
- package/dist/model/operations/create-operation.d.ts +31 -0
- package/dist/model/operations/destroy-operation.d.ts +65 -0
- package/dist/model/operations/find-cursor.d.ts +23 -0
- package/dist/model/operations/find-lookups.d.ts +99 -0
- package/dist/model/operations/find-operation.d.ts +47 -0
- package/dist/model/operations/increment-operation.d.ts +40 -0
- package/dist/model/operations/insert-operation.d.ts +71 -0
- package/dist/model/operations/merge-operation.d.ts +56 -0
- package/dist/model/operations/model-operation.d.ts +33 -0
- package/dist/model/operations/update-operation.d.ts +45 -0
- package/dist/model/operations/upsert-operation.d.ts +39 -0
- package/dist/model/options.d.ts +103 -0
- package/dist/model/returning-old.d.ts +52 -0
- package/dist/model/row-mapper.d.ts +78 -0
- package/dist/model/row-plan.d.ts +31 -0
- package/dist/model/runtime.d.ts +56 -0
- package/dist/model/scope-registry.d.ts +81 -0
- package/dist/model/select-aggregates.d.ts +37 -0
- package/dist/model/select-lock.d.ts +13 -0
- package/dist/model/select-options.d.ts +92 -0
- package/dist/model/select-query-builder.d.ts +73 -0
- package/dist/model/select-targets.d.ts +77 -0
- package/dist/model/source-option-builder.d.ts +23 -0
- package/dist/model/source-options.d.ts +108 -0
- package/dist/model/statement-builder.d.ts +77 -0
- package/dist/model/statement-services.d.ts +2 -0
- package/dist/model/sync-hooks.d.ts +18 -0
- package/dist/model/table-sample-builder.d.ts +13 -0
- package/dist/model/types.d.ts +85 -0
- package/dist/model/unnest-insert-builder.d.ts +24 -0
- package/dist/model/update-query-builder.d.ts +39 -0
- package/dist/model/v6-conflict-builder.d.ts +37 -0
- package/dist/model/value-cloner.d.ts +17 -0
- package/dist/model/values-writer.d.ts +12 -0
- package/dist/model/where-options.d.ts +164 -0
- package/dist/model/write-options.d.ts +160 -0
- package/dist/model/written-rows.d.ts +56 -0
- package/dist/package-version.d.ts +8 -0
- package/dist/query/query-result-shaper.d.ts +93 -0
- package/dist/query/raw-query.d.ts +27 -0
- package/dist/query-interface/alter-planner.d.ts +40 -0
- package/dist/query-interface/bulk-data.d.ts +44 -0
- package/dist/query-interface/column-commands.d.ts +52 -0
- package/dist/query-interface/column-describer.d.ts +17 -0
- package/dist/query-interface/enum-commands.d.ts +36 -0
- package/dist/query-interface/index-commands.d.ts +57 -0
- package/dist/query-interface/model-tables.d.ts +58 -0
- package/dist/query-interface/object-commands.d.ts +71 -0
- package/dist/query-interface/partition-commands.d.ts +43 -0
- package/dist/query-interface/policy-commands.d.ts +54 -0
- package/dist/query-interface/query-interface-catalog.d.ts +180 -0
- package/dist/query-interface/query-interface-objects.d.ts +108 -0
- package/dist/query-interface/query-interface-partitions.d.ts +66 -0
- package/dist/query-interface/query-interface-policies.d.ts +86 -0
- package/dist/query-interface/query-interface-routines.d.ts +120 -0
- package/dist/query-interface/query-interface-tables.d.ts +179 -0
- package/dist/query-interface/query-interface-types.d.ts +62 -0
- package/dist/query-interface/query-interface-views.d.ts +84 -0
- package/dist/query-interface/query-interface.d.ts +256 -0
- package/dist/query-interface/routine-commands.d.ts +71 -0
- package/dist/query-interface/schema-synchronizer.d.ts +110 -0
- package/dist/query-interface/statement-runner.d.ts +40 -0
- package/dist/query-interface/sync-planner.d.ts +26 -0
- package/dist/query-interface/table-commands.d.ts +63 -0
- package/dist/query-interface/table-introspector.d.ts +58 -0
- package/dist/query-interface/view-commands.d.ts +47 -0
- package/dist/sequelize/instance-hook-adders.d.ts +72 -0
- package/dist/sequelize/sequelize-base.d.ts +196 -0
- package/dist/sequelize/sequelize-constructor.d.ts +7 -0
- package/dist/sequelize/sequelize-helpers.d.ts +133 -0
- package/dist/sequelize/sequelize-hooks.d.ts +99 -0
- package/dist/sequelize/sequelize-internals.d.ts +87 -0
- package/dist/sequelize/sequelize-notifications.d.ts +66 -0
- package/dist/sequelize/sequelize-schema.d.ts +125 -0
- package/dist/sequelize/sequelize-transactions.d.ts +96 -0
- package/dist/sequelize.d.ts +1175 -0
- package/dist/sql/ast-clauses.d.ts +137 -0
- package/dist/sql/ast-expressions.d.ts +88 -0
- package/dist/sql/ast-statements.d.ts +80 -0
- package/dist/sql/ast.d.ts +21 -0
- package/dist/sql/compile.d.ts +21 -0
- package/dist/sql/dml-compiler.d.ts +54 -0
- package/dist/sql/expression-compiler.d.ts +56 -0
- package/dist/sql/from-compiler.d.ts +39 -0
- package/dist/sql/identifier-quoter.d.ts +15 -0
- package/dist/sql/merge-compiler.d.ts +20 -0
- package/dist/sql/order.d.ts +15 -0
- package/dist/sql/query-compiler.d.ts +45 -0
- package/dist/sql/sql-chunks.d.ts +50 -0
- package/dist/sql/with-compiler.d.ts +19 -0
- package/dist/transaction/advisory-locks.d.ts +28 -0
- package/dist/transaction/cls-namespace.d.ts +44 -0
- package/dist/transaction/transaction-constants.d.ts +35 -0
- package/dist/transaction/transaction-runner.d.ts +78 -0
- package/dist/transaction/transaction-starter.d.ts +25 -0
- package/dist/transaction/transaction-statements.d.ts +29 -0
- package/dist/transaction/transaction.d.ts +201 -0
- package/dist/validation/attribute-validators.d.ts +23 -0
- package/dist/validation/builtin-attribute-validator.d.ts +19 -0
- package/dist/validation/builtin-validators.d.ts +16 -0
- package/dist/validation/core-validator.d.ts +16 -0
- package/dist/validation/custom-validators.d.ts +13 -0
- package/dist/validation/instance-validator.d.ts +25 -0
- package/dist/validation/schema-items.d.ts +22 -0
- package/dist/validation/standard-schema-validator.d.ts +30 -0
- package/dist/validation/standard-schema.d.ts +39 -0
- package/dist/validation/types.d.ts +36 -0
- package/dist/validation/validation-target.d.ts +13 -0
- package/dist/where/comparison-compiler.d.ts +27 -0
- package/dist/where/condition-compiler.d.ts +18 -0
- package/dist/where/operand-resolver.d.ts +10 -0
- package/dist/where/operator-allowlist.d.ts +14 -0
- package/dist/where/where-support.d.ts +52 -0
- package/dist/where/where.d.ts +46 -0
- package/dist/where/window-compiler.d.ts +14 -0
- package/llm/USAGE.md +423 -0
- package/package.json +103 -4
- package/skills/postgrelize/SKILL.md +57 -0
- package/skills/postgrelize/reference/associations.md +108 -0
- package/skills/postgrelize/reference/errors.md +37 -0
- package/skills/postgrelize/reference/migrating-from-sequelize.md +15 -0
- package/skills/postgrelize/reference/postgresql-features.md +157 -0
- package/skills/postgrelize/reference/querying.md +111 -0
- package/skills/postgrelize/reference/schema.md +135 -0
- package/skills/postgrelize/reference/security.md +34 -0
- package/skills/postgrelize/reference/transactions-and-sessions.md +122 -0
- package/skills/postgrelize/reference/writing.md +198 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { Model } from './model.ts';
|
|
2
|
+
import { Values } from './options.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Value access of model instances: `get`, `set`, `getDataValue`, `setDataValue`, `changed`, `previous`, `equals`, `toJSON`.
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare class ModelInstanceValues<TAttributes extends object = Values> {
|
|
9
|
+
/** Current attribute values. */
|
|
10
|
+
dataValues: TAttributes;
|
|
11
|
+
/**
|
|
12
|
+
* Returns all attribute values of the instance; no query is run.
|
|
13
|
+
*
|
|
14
|
+
* @param options - `plain: true` returns a copy of all values with custom getters applied; `raw: true` skips custom getters.
|
|
15
|
+
* @returns Values object.
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* const values = user.get({ plain: true });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
get(options?: Readonly<{
|
|
22
|
+
plain?: boolean;
|
|
23
|
+
raw?: boolean;
|
|
24
|
+
clone?: boolean;
|
|
25
|
+
}>): TAttributes;
|
|
26
|
+
/**
|
|
27
|
+
* Returns one attribute value, applying its custom getter unless `raw` is set.
|
|
28
|
+
*
|
|
29
|
+
* @param key - Attribute name.
|
|
30
|
+
* @param options - `raw: true` skips the custom getter.
|
|
31
|
+
* @returns Attribute value.
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* const email = user.get('email');
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
get<K extends keyof TAttributes>(key: K, options?: Readonly<{
|
|
38
|
+
raw?: boolean;
|
|
39
|
+
}>): TAttributes[K];
|
|
40
|
+
/**
|
|
41
|
+
* Sets one attribute value, applying its custom setter unless `raw` is set. Nothing is written to
|
|
42
|
+
* the database until {@link Model.save}; the attribute is marked as changed when the value differs.
|
|
43
|
+
*
|
|
44
|
+
* @param key - Attribute name.
|
|
45
|
+
* @param value - New value.
|
|
46
|
+
* @param options - `raw: true` skips the custom setter and change tracking.
|
|
47
|
+
* @returns This instance.
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* user.set('email', 'ada@example.com');
|
|
51
|
+
* await user.save();
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
set<K extends keyof TAttributes>(key: K, value: TAttributes[K], options?: Readonly<{
|
|
55
|
+
raw?: boolean;
|
|
56
|
+
}>): this;
|
|
57
|
+
/**
|
|
58
|
+
* Sets several attribute values at once, applying custom setters unless `raw` is set.
|
|
59
|
+
*
|
|
60
|
+
* @param values - Attribute values.
|
|
61
|
+
* @param options - `raw: true` skips custom setters and change tracking.
|
|
62
|
+
* @returns This instance.
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* user.set({ email: 'ada@example.com', active: true });
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
set(values: Partial<TAttributes> | Values, options?: Readonly<{
|
|
69
|
+
raw?: boolean;
|
|
70
|
+
}>): this;
|
|
71
|
+
/**
|
|
72
|
+
* Reads the stored value of an attribute, bypassing its custom getter.
|
|
73
|
+
*
|
|
74
|
+
* @param key - Attribute name.
|
|
75
|
+
* @returns Raw value.
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* const stored = user.getDataValue('email');
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
getDataValue<K extends keyof TAttributes>(key: K): TAttributes[K];
|
|
82
|
+
/**
|
|
83
|
+
* Writes the stored value of an attribute, bypassing its custom setter, and marks it as changed.
|
|
84
|
+
*
|
|
85
|
+
* @param key - Attribute name.
|
|
86
|
+
* @param value - New value.
|
|
87
|
+
* @returns This instance.
|
|
88
|
+
* @example
|
|
89
|
+
* ```ts
|
|
90
|
+
* user.setDataValue('email', 'ada@example.com');
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
setDataValue<K extends keyof TAttributes>(key: K, value: TAttributes[K]): this;
|
|
94
|
+
/**
|
|
95
|
+
* Lists the attributes changed since the instance was loaded or last saved.
|
|
96
|
+
*
|
|
97
|
+
* @returns Changed attribute names, or `false` when nothing changed.
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* user.set('email', 'ada@example.com');
|
|
101
|
+
* const changedFields = user.changed();
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
changed(): (keyof TAttributes & string)[] | false;
|
|
105
|
+
/**
|
|
106
|
+
* Checks whether one attribute changed since the instance was loaded or last saved.
|
|
107
|
+
*
|
|
108
|
+
* @param key - Attribute name.
|
|
109
|
+
* @returns True when changed.
|
|
110
|
+
*/
|
|
111
|
+
changed(key: keyof TAttributes & string): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Marks an attribute as changed or unchanged, which controls whether {@link Model.save} writes it.
|
|
114
|
+
*
|
|
115
|
+
* @param key - Attribute name.
|
|
116
|
+
* @param value - Changed flag.
|
|
117
|
+
*/
|
|
118
|
+
changed(key: keyof TAttributes & string, value: boolean): void;
|
|
119
|
+
/**
|
|
120
|
+
* Returns the value an attribute had before it was changed, or all previous values of changed
|
|
121
|
+
* attributes when no key is given.
|
|
122
|
+
*
|
|
123
|
+
* @param key - Attribute name; omit to get all.
|
|
124
|
+
* @returns Previous value(s).
|
|
125
|
+
* @example
|
|
126
|
+
* ```ts
|
|
127
|
+
* user.set('email', 'ada@example.com');
|
|
128
|
+
* const before = user.previous('email');
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
previous<K extends keyof TAttributes>(key?: K): TAttributes[K] | Partial<TAttributes> | undefined;
|
|
132
|
+
/**
|
|
133
|
+
* Compares the primary keys of two instances.
|
|
134
|
+
*
|
|
135
|
+
* @param other - Instance to compare with.
|
|
136
|
+
* @returns True when all primary key values are equal.
|
|
137
|
+
* @example
|
|
138
|
+
* ```ts
|
|
139
|
+
* const other = User.build({ id: user.get('id') });
|
|
140
|
+
* const same = user.equals(other);
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
equals(other: Model): boolean;
|
|
144
|
+
/**
|
|
145
|
+
* Tells whether the instance equals any of the given instances (same model and primary keys).
|
|
146
|
+
*
|
|
147
|
+
* @param others - Instances to compare with.
|
|
148
|
+
* @returns True when at least one equals this instance.
|
|
149
|
+
* @example
|
|
150
|
+
* ```ts
|
|
151
|
+
* const known = user.equalsOneOf(users);
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
equalsOneOf(others: readonly Model[]): boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Alias of {@link Model.set} for several values (Sequelize v6 `setAttributes`).
|
|
157
|
+
*
|
|
158
|
+
* @param updates - Attribute values.
|
|
159
|
+
* @returns This instance.
|
|
160
|
+
* @example
|
|
161
|
+
* ```ts
|
|
162
|
+
* user.setAttributes({ email: 'ada@example.com' });
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
setAttributes(updates: Partial<TAttributes> | Values): this;
|
|
166
|
+
/**
|
|
167
|
+
* Condition that selects this row: its primary key values keyed by column name.
|
|
168
|
+
*
|
|
169
|
+
* @param checkVersion - Also match the optimistic-locking `version` value.
|
|
170
|
+
* @returns The where object (the model's `whereCollection` option when it has no primary key).
|
|
171
|
+
* @example
|
|
172
|
+
* ```ts
|
|
173
|
+
* const where = user.where();
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
where(checkVersion?: boolean): Record<string, unknown> | undefined;
|
|
177
|
+
/**
|
|
178
|
+
* Describes the instance as `[object SequelizeInstance:Model]`.
|
|
179
|
+
*
|
|
180
|
+
* @returns The description.
|
|
181
|
+
* @example
|
|
182
|
+
* ```ts
|
|
183
|
+
* String(user); // '[object SequelizeInstance:User]'
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
toString(): string;
|
|
187
|
+
/**
|
|
188
|
+
* Returns a deep copy of the values with custom getters applied, used by `JSON.stringify`.
|
|
189
|
+
*
|
|
190
|
+
* @returns Plain object.
|
|
191
|
+
* @example
|
|
192
|
+
* ```ts
|
|
193
|
+
* const json = JSON.stringify(user);
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
toJSON(): TAttributes;
|
|
197
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BulkCreateOperation } from './operations/bulk-create-operation.ts';
|
|
2
|
+
import { CopyOperation } from './operations/copy-operation.ts';
|
|
3
|
+
import { CountOperation } from './operations/count-operation.ts';
|
|
4
|
+
import { CreateOperation } from './operations/create-operation.ts';
|
|
5
|
+
import { DestroyOperation } from './operations/destroy-operation.ts';
|
|
6
|
+
import { FindOperation } from './operations/find-operation.ts';
|
|
7
|
+
import { IncrementOperation } from './operations/increment-operation.ts';
|
|
8
|
+
import { InsertOperation } from './operations/insert-operation.ts';
|
|
9
|
+
import { MergeOperation } from './operations/merge-operation.ts';
|
|
10
|
+
import { UpdateOperation } from './operations/update-operation.ts';
|
|
11
|
+
import { UpsertOperation } from './operations/upsert-operation.ts';
|
|
12
|
+
export declare const finder: FindOperation;
|
|
13
|
+
export declare const counter: CountOperation;
|
|
14
|
+
export declare const inserter: InsertOperation;
|
|
15
|
+
export declare const creator: CreateOperation;
|
|
16
|
+
export declare const bulkCreator: BulkCreateOperation;
|
|
17
|
+
export declare const upserter: UpsertOperation;
|
|
18
|
+
export declare const updater: UpdateOperation;
|
|
19
|
+
export declare const destroyer: DestroyOperation;
|
|
20
|
+
export declare const incrementer: IncrementOperation;
|
|
21
|
+
export declare const merger: MergeOperation;
|
|
22
|
+
export declare const copier: CopyOperation;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { HookFunction, HookType } from '../hooks/hooks.ts';
|
|
2
|
+
import { ModelAttributes, ModelDefinition } from './model-definition.ts';
|
|
3
|
+
import { ModelState } from './model-state.ts';
|
|
4
|
+
import { InitOptions } from './options.ts';
|
|
5
|
+
import { RuntimeOwner } from './runtime.ts';
|
|
6
|
+
import { ScopeDefinition, ScopeOptions, ScopeSelector } from './scope-registry.ts';
|
|
7
|
+
export type { ModelState } from './model-state.ts';
|
|
8
|
+
/**
|
|
9
|
+
* Per-class state of models: definition, runtime, hooks, scopes, validators and associations of
|
|
10
|
+
* each initialized model class (shared by its scoped subclasses), the scopes selected by
|
|
11
|
+
* `Model.scope()`, and the attribute / association accessors installed on model prototypes.
|
|
12
|
+
* Instances share one store, so they can be created wherever needed.
|
|
13
|
+
*/
|
|
14
|
+
export declare class ModelRegistry {
|
|
15
|
+
#private;
|
|
16
|
+
/**
|
|
17
|
+
* Initializes a model class (`Model.init`): normalizes the definition, stores the state,
|
|
18
|
+
* installs attribute accessors and registers the model in `sequelize.models`.
|
|
19
|
+
*
|
|
20
|
+
* @param model - Model class.
|
|
21
|
+
* @param attributes - Attribute definitions.
|
|
22
|
+
* @param options - Model options, including the `sequelize` instance.
|
|
23
|
+
*/
|
|
24
|
+
init(model: Readonly<{
|
|
25
|
+
name: string;
|
|
26
|
+
prototype: object;
|
|
27
|
+
}>, attributes: ModelAttributes, options: InitOptions): void;
|
|
28
|
+
/**
|
|
29
|
+
* State of a model class or of a scoped subclass of it.
|
|
30
|
+
*
|
|
31
|
+
* @param model - Model class.
|
|
32
|
+
* @returns The state.
|
|
33
|
+
* @throws Error when the model is not initialized.
|
|
34
|
+
*/
|
|
35
|
+
state(model: object): ModelState;
|
|
36
|
+
/**
|
|
37
|
+
* Normalized definition of a model class.
|
|
38
|
+
*
|
|
39
|
+
* @param model - Model class.
|
|
40
|
+
* @returns The definition.
|
|
41
|
+
*/
|
|
42
|
+
definition(model: object): ModelDefinition;
|
|
43
|
+
/**
|
|
44
|
+
* Replaces the state of the model that owns `model` (scoped subclasses share it).
|
|
45
|
+
*
|
|
46
|
+
* @param model - Model class.
|
|
47
|
+
* @param change - Computes the new state from the current one.
|
|
48
|
+
*/
|
|
49
|
+
update(model: object, change: (state: ModelState) => ModelState): void;
|
|
50
|
+
/**
|
|
51
|
+
* `Sequelize` instance given to `Model.init` for exactly this class.
|
|
52
|
+
*
|
|
53
|
+
* @param model - Model class.
|
|
54
|
+
* @returns The instance, or `undefined`.
|
|
55
|
+
*/
|
|
56
|
+
sequelizeOf(model: object): RuntimeOwner | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Adds a hook to a model.
|
|
59
|
+
*
|
|
60
|
+
* @param model - Model class.
|
|
61
|
+
* @param type - Hook type.
|
|
62
|
+
* @param nameOrFn - Hook name or function.
|
|
63
|
+
* @param fn - Hook function when a name is given.
|
|
64
|
+
*/
|
|
65
|
+
addHook(model: object, type: HookType, nameOrFn: string | HookFunction, fn: HookFunction | undefined): void;
|
|
66
|
+
/**
|
|
67
|
+
* Removes hooks of a model by name or function.
|
|
68
|
+
*
|
|
69
|
+
* @param model - Model class.
|
|
70
|
+
* @param type - Hook type.
|
|
71
|
+
* @param nameOrFn - Hook name or function; all hooks of the type when omitted.
|
|
72
|
+
*/
|
|
73
|
+
removeHook(model: object, type: HookType, nameOrFn: string | HookFunction | undefined): void;
|
|
74
|
+
/**
|
|
75
|
+
* Adds a named scope (or replaces the default scope with name `'defaultScope'`).
|
|
76
|
+
*
|
|
77
|
+
* @param model - Model class.
|
|
78
|
+
* @param name - Scope name.
|
|
79
|
+
* @param scope - Options or a function returning options.
|
|
80
|
+
* @param override - Replace an existing scope.
|
|
81
|
+
* @throws Error when the scope exists and `override` is not set.
|
|
82
|
+
*/
|
|
83
|
+
addScope(model: object, name: string, scope: ScopeDefinition, override: boolean): void;
|
|
84
|
+
/**
|
|
85
|
+
* Marks `scoped` (a subclass of `model`) as using the given scopes, checking that they resolve.
|
|
86
|
+
*
|
|
87
|
+
* @param model - Model class whose scopes are used.
|
|
88
|
+
* @param scoped - Scoped subclass.
|
|
89
|
+
* @param selectors - Selected scopes.
|
|
90
|
+
*/
|
|
91
|
+
selectScopes(model: object, scoped: object, selectors: readonly ScopeSelector[]): void;
|
|
92
|
+
/**
|
|
93
|
+
* Gives `bound` (a subclass of `model`) its own state bound to a schema, and the scope
|
|
94
|
+
* selection of `model`.
|
|
95
|
+
*
|
|
96
|
+
* @param model - Model class the copy extends.
|
|
97
|
+
* @param bound - Schema-bound subclass.
|
|
98
|
+
* @param schema - Schema name.
|
|
99
|
+
* @param delimiter - Separator reported by `getTableName`.
|
|
100
|
+
*/
|
|
101
|
+
bindSchema(model: object, bound: object, schema: string, delimiter: string | undefined): void;
|
|
102
|
+
/**
|
|
103
|
+
* Scope options in effect for `model`: its selected scopes, or the default scope.
|
|
104
|
+
*
|
|
105
|
+
* @param model - Model class.
|
|
106
|
+
* @returns Scope options.
|
|
107
|
+
*/
|
|
108
|
+
activeScope(model: object): ScopeOptions;
|
|
109
|
+
/**
|
|
110
|
+
* Query options with the active scope of `model` applied (query options win).
|
|
111
|
+
*
|
|
112
|
+
* @param model - Model class.
|
|
113
|
+
* @param options - Query options.
|
|
114
|
+
* @returns Merged options.
|
|
115
|
+
*/
|
|
116
|
+
scoped<T extends ScopeOptions>(model: object, options: T): T;
|
|
117
|
+
/**
|
|
118
|
+
* Defines `instance.<attribute>` getters / setters on the model prototype (once per attribute).
|
|
119
|
+
*
|
|
120
|
+
* @param prototype - Model prototype.
|
|
121
|
+
* @param definition - Model definition.
|
|
122
|
+
*/
|
|
123
|
+
defineAttributeAccessors(prototype: object, definition: ModelDefinition): void;
|
|
124
|
+
/**
|
|
125
|
+
* Defines `instance.<alias>` for an association, holding included / nested instances (Sequelize v6).
|
|
126
|
+
*
|
|
127
|
+
* @param prototype - Model prototype.
|
|
128
|
+
* @param alias - Association alias.
|
|
129
|
+
*/
|
|
130
|
+
defineAssociationAccessor(prototype: object, alias: string): void;
|
|
131
|
+
/**
|
|
132
|
+
* Rebuilds the definition of `model` with attributes contributed by associations.
|
|
133
|
+
*
|
|
134
|
+
* @param model - Model class.
|
|
135
|
+
* @param attributes - Added attributes (foreign keys).
|
|
136
|
+
* @returns The new definition.
|
|
137
|
+
*/
|
|
138
|
+
addAssociationAttributes(model: object, attributes: ModelAttributes): ModelDefinition;
|
|
139
|
+
/**
|
|
140
|
+
* Removes an attribute and rebuilds the definition (`Model.removeAttribute`).
|
|
141
|
+
*
|
|
142
|
+
* @param model - Model class.
|
|
143
|
+
* @param attribute - Attribute name.
|
|
144
|
+
*/
|
|
145
|
+
removeAttribute(model: object, attribute: string): void;
|
|
146
|
+
/**
|
|
147
|
+
* Rebuilds the definition from the `init` input (`Model.refreshAttributes`).
|
|
148
|
+
*
|
|
149
|
+
* @param model - Model class.
|
|
150
|
+
*/
|
|
151
|
+
refreshAttributes(model: object): void;
|
|
152
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { IncludeLoader } from '../associations/include-loader.ts';
|
|
2
|
+
import { IncludeQueryBuilder } from '../associations/include-query-builder.ts';
|
|
3
|
+
import { IncludeResolver } from '../associations/include-resolver.ts';
|
|
4
|
+
import { NestedCreator } from '../associations/nested-creator.ts';
|
|
5
|
+
import { SqlCompiler } from '../sql/compile.ts';
|
|
6
|
+
import { AttributeColumns } from './attribute-columns.ts';
|
|
7
|
+
import { CteBuilder } from './cte-builder.ts';
|
|
8
|
+
import { DeleteQueryBuilder } from './delete-query-builder.ts';
|
|
9
|
+
import { FindQueryBuilder } from './find-query-builder.ts';
|
|
10
|
+
import { InsertQueryBuilder } from './insert-query-builder.ts';
|
|
11
|
+
import { InstanceLifecycle } from './instance-lifecycle.ts';
|
|
12
|
+
import { SyncHooks } from './sync-hooks.ts';
|
|
13
|
+
import { InstanceValues } from './instance-values.ts';
|
|
14
|
+
import { JoinSourceBuilder } from './join-source-builder.ts';
|
|
15
|
+
import { ModelRegistry } from './model-registry.ts';
|
|
16
|
+
import { ModelValues } from './model-values.ts';
|
|
17
|
+
import { OnConflictBuilder } from './on-conflict-builder.ts';
|
|
18
|
+
import { ReturningOld } from './returning-old.ts';
|
|
19
|
+
import { RowMapper } from './row-mapper.ts';
|
|
20
|
+
import { SelectQueryBuilder } from './select-query-builder.ts';
|
|
21
|
+
import { UpdateQueryBuilder } from './update-query-builder.ts';
|
|
22
|
+
import { ValueCloner } from './value-cloner.ts';
|
|
23
|
+
import { WrittenRows } from './written-rows.ts';
|
|
24
|
+
export declare const registry: ModelRegistry;
|
|
25
|
+
export declare const attributeColumns: AttributeColumns;
|
|
26
|
+
export declare const modelValues: ModelValues;
|
|
27
|
+
export declare const valueCloner: ValueCloner;
|
|
28
|
+
export declare const rowMapper: RowMapper;
|
|
29
|
+
export declare const sqlCompiler: SqlCompiler;
|
|
30
|
+
export declare const selectQueries: SelectQueryBuilder;
|
|
31
|
+
export declare const insertQueries: InsertQueryBuilder;
|
|
32
|
+
export declare const updateQueries: UpdateQueryBuilder;
|
|
33
|
+
export declare const deleteQueries: DeleteQueryBuilder;
|
|
34
|
+
export declare const joinSources: JoinSourceBuilder;
|
|
35
|
+
export declare const cteBuilder: CteBuilder;
|
|
36
|
+
export declare const onConflictBuilder: OnConflictBuilder;
|
|
37
|
+
export declare const returningOld: ReturningOld;
|
|
38
|
+
export declare const writtenRows: WrittenRows;
|
|
39
|
+
export declare const includeResolver: IncludeResolver;
|
|
40
|
+
export declare const includeQueries: IncludeQueryBuilder;
|
|
41
|
+
export declare const includeLoader: IncludeLoader;
|
|
42
|
+
export declare const nestedCreator: NestedCreator;
|
|
43
|
+
export declare const findQueries: FindQueryBuilder;
|
|
44
|
+
export declare const instanceValues: InstanceValues;
|
|
45
|
+
export declare const lifecycle: InstanceLifecycle;
|
|
46
|
+
export declare const syncHooks: SyncHooks;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { HookRegistry } from '../hooks/hooks.ts';
|
|
2
|
+
import { StandardSchemaV1 } from '../validation/standard-schema.ts';
|
|
3
|
+
import { ModelValidatorFunction } from '../validation/types.ts';
|
|
4
|
+
import { ModelDefinition, DefinitionOptions, ModelAttributes } from './model-definition.ts';
|
|
5
|
+
import { InitOptions } from './options.ts';
|
|
6
|
+
import { ModelRuntime } from './runtime.ts';
|
|
7
|
+
import { ScopeRegistry } from './scope-registry.ts';
|
|
8
|
+
/** Internal state of an initialized model class. */
|
|
9
|
+
export type ModelState = Readonly<{
|
|
10
|
+
definition: ModelDefinition;
|
|
11
|
+
runtime: ModelRuntime;
|
|
12
|
+
hooks: HookRegistry;
|
|
13
|
+
scopes: ScopeRegistry;
|
|
14
|
+
validators: Readonly<Record<string, ModelValidatorFunction>>;
|
|
15
|
+
schema: StandardSchemaV1 | undefined;
|
|
16
|
+
/** `init` input, kept to rebuild the definition when associations add attributes. */
|
|
17
|
+
input: Readonly<{
|
|
18
|
+
className: string;
|
|
19
|
+
attributes: ModelAttributes;
|
|
20
|
+
options: DefinitionOptions;
|
|
21
|
+
extra: ModelAttributes;
|
|
22
|
+
}>;
|
|
23
|
+
/** Associations by alias. */
|
|
24
|
+
associations: ReadonlyMap<string, unknown>;
|
|
25
|
+
}>;
|
|
26
|
+
/**
|
|
27
|
+
* Builds the state of a model class from `Model.init` arguments, and rebuilds it when
|
|
28
|
+
* associations add attributes.
|
|
29
|
+
*
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
export declare class ModelStateFactory {
|
|
33
|
+
#private;
|
|
34
|
+
/**
|
|
35
|
+
* State of a model class just initialized by `Model.init`.
|
|
36
|
+
*
|
|
37
|
+
* @param className - Class name (default model name).
|
|
38
|
+
* @param attributes - Attribute definitions.
|
|
39
|
+
* @param options - Model options, including the `sequelize` instance.
|
|
40
|
+
* @returns The state.
|
|
41
|
+
*/
|
|
42
|
+
create(className: string, attributes: ModelAttributes, options: InitOptions): ModelState;
|
|
43
|
+
/**
|
|
44
|
+
* State with the definition rebuilt from the `init` input plus attributes of associations.
|
|
45
|
+
*
|
|
46
|
+
* @param state - Current state.
|
|
47
|
+
* @param attributes - Added attributes (foreign keys).
|
|
48
|
+
* @returns The new state.
|
|
49
|
+
*/
|
|
50
|
+
withAssociationAttributes(state: ModelState, attributes: ModelAttributes): ModelState;
|
|
51
|
+
/**
|
|
52
|
+
* State with an attribute removed from the `init` input and the added attributes.
|
|
53
|
+
*
|
|
54
|
+
* @param state - Current state.
|
|
55
|
+
* @param attribute - Attribute name.
|
|
56
|
+
* @returns The new state.
|
|
57
|
+
*/
|
|
58
|
+
withoutAttribute(state: ModelState, attribute: string): ModelState;
|
|
59
|
+
/**
|
|
60
|
+
* State of a schema-bound copy of a model: the definition is rebuilt with the schema.
|
|
61
|
+
*
|
|
62
|
+
* @param state - State of the model the copy extends.
|
|
63
|
+
* @param schema - Schema name.
|
|
64
|
+
* @param delimiter - Separator reported by `getTableName`, `.` when not given.
|
|
65
|
+
* @returns The new state.
|
|
66
|
+
*/
|
|
67
|
+
withSchema(state: ModelState, schema: string, delimiter: string | undefined): ModelState;
|
|
68
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { ModelDefinition } from './model-definition.ts';
|
|
2
|
+
import { AttributeAmounts, Values } from './options.ts';
|
|
3
|
+
import { QueryOptionsBase } from './runtime.ts';
|
|
4
|
+
/**
|
|
5
|
+
* Attribute value rules of model operations: change detection, defaults, timestamps, field
|
|
6
|
+
* selection, increment amounts, values taken from `where`, and the query options passed on to
|
|
7
|
+
* nested queries.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ModelValues {
|
|
10
|
+
#private;
|
|
11
|
+
/**
|
|
12
|
+
* Whether two attribute values are equal (dates by time, objects by JSON).
|
|
13
|
+
*
|
|
14
|
+
* @param left - First value.
|
|
15
|
+
* @param right - Second value.
|
|
16
|
+
* @returns True when equal.
|
|
17
|
+
*/
|
|
18
|
+
isEqual(left: unknown, right: unknown): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Values of a new instance: attribute defaults and `null` primary keys.
|
|
21
|
+
*
|
|
22
|
+
* @param definition - Model definition.
|
|
23
|
+
* @returns Initial values.
|
|
24
|
+
*/
|
|
25
|
+
initial(definition: ModelDefinition): Values;
|
|
26
|
+
/**
|
|
27
|
+
* Amount per attribute of `increment` / `decrement`.
|
|
28
|
+
*
|
|
29
|
+
* @param fields - Attribute name(s), or a map of attribute to amount.
|
|
30
|
+
* @param by - Amount for names.
|
|
31
|
+
* @returns Amount per attribute.
|
|
32
|
+
*/
|
|
33
|
+
amounts(fields: AttributeAmounts<Values>, by: number): Readonly<Record<string, number>>;
|
|
34
|
+
/**
|
|
35
|
+
* Values restricted to `fields` (all values when `fields` is not given).
|
|
36
|
+
*
|
|
37
|
+
* @param values - Values.
|
|
38
|
+
* @param fields - Attribute names.
|
|
39
|
+
* @returns Picked values.
|
|
40
|
+
*/
|
|
41
|
+
pick(values: Values, fields: readonly string[] | undefined): Values;
|
|
42
|
+
/**
|
|
43
|
+
* Explicit `fields` of `save` / `create` extended like v6: `updatedAt` and the version
|
|
44
|
+
* attribute (when anything is written), and for an INSERT `createdAt` and primary keys that
|
|
45
|
+
* have a default.
|
|
46
|
+
*
|
|
47
|
+
* @param definition - Model definition.
|
|
48
|
+
* @param fields - Fields as given, or `undefined`.
|
|
49
|
+
* @param creating - Whether the row is inserted.
|
|
50
|
+
* @returns Fields to write (`undefined` when none were given).
|
|
51
|
+
*/
|
|
52
|
+
saveFields(definition: ModelDefinition, fields: readonly string[] | undefined, creating: boolean): readonly string[] | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Explicit `fields` of `bulkCreate` extended with the timestamp attributes, like v6.
|
|
55
|
+
*
|
|
56
|
+
* @param definition - Model definition.
|
|
57
|
+
* @param fields - Fields as given, or `undefined`.
|
|
58
|
+
* @returns Fields to write (`undefined` when none were given).
|
|
59
|
+
*/
|
|
60
|
+
bulkFields(definition: ModelDefinition, fields: readonly string[] | undefined): readonly string[] | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Query options passed on to nested queries: `transaction`, `logging`, `benchmark`.
|
|
63
|
+
*
|
|
64
|
+
* @param options - Options of the outer call.
|
|
65
|
+
* @returns Query options.
|
|
66
|
+
*/
|
|
67
|
+
queryOptions(options: QueryOptionsBase): QueryOptionsBase;
|
|
68
|
+
/**
|
|
69
|
+
* Sets `createdAt` (on creation, when empty) and `updatedAt` (unless `silent`).
|
|
70
|
+
*
|
|
71
|
+
* @param definition - Model definition.
|
|
72
|
+
* @param values - Values.
|
|
73
|
+
* @param now - Timestamp.
|
|
74
|
+
* @param creating - Whether the row is inserted.
|
|
75
|
+
* @param silent - `silent` option.
|
|
76
|
+
* @returns Values with timestamps.
|
|
77
|
+
*/
|
|
78
|
+
withTimestamps(definition: ModelDefinition, values: Values, now: Date, creating: boolean, silent: boolean): Values;
|
|
79
|
+
/**
|
|
80
|
+
* Plain values of a `where` object (used as defaults by `findOrCreate` / `findOrBuild`).
|
|
81
|
+
*
|
|
82
|
+
* @param where - Condition.
|
|
83
|
+
* @returns Attribute values compared with `=`.
|
|
84
|
+
*/
|
|
85
|
+
fromWhere(where: unknown): Values;
|
|
86
|
+
}
|