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.
Files changed (319) hide show
  1. package/CHANGELOG.md +289 -0
  2. package/LICENSE +21 -0
  3. package/README.md +131 -2
  4. package/dist/associations/alias-minifier.d.ts +43 -0
  5. package/dist/associations/association-accessors.d.ts +21 -0
  6. package/dist/associations/association-key-types.d.ts +44 -0
  7. package/dist/associations/association-keys.d.ts +98 -0
  8. package/dist/associations/association-lookup.d.ts +26 -0
  9. package/dist/associations/association-shape.d.ts +25 -0
  10. package/dist/associations/association.d.ts +95 -0
  11. package/dist/associations/belongs-to-many.d.ts +86 -0
  12. package/dist/associations/belongs-to.d.ts +45 -0
  13. package/dist/associations/has-many.d.ts +79 -0
  14. package/dist/associations/has-one.d.ts +44 -0
  15. package/dist/associations/include-assembler.d.ts +21 -0
  16. package/dist/associations/include-columns.d.ts +24 -0
  17. package/dist/associations/include-joins.d.ts +17 -0
  18. package/dist/associations/include-loader.d.ts +48 -0
  19. package/dist/associations/include-order.d.ts +22 -0
  20. package/dist/associations/include-query-builder.d.ts +54 -0
  21. package/dist/associations/include-resolver.d.ts +29 -0
  22. package/dist/associations/include-rows.d.ts +47 -0
  23. package/dist/associations/include-sub-query.d.ts +35 -0
  24. package/dist/associations/include.d.ts +112 -0
  25. package/dist/associations/junction-keys.d.ts +23 -0
  26. package/dist/associations/nested-creator.d.ts +44 -0
  27. package/dist/associations/nested-saver.d.ts +30 -0
  28. package/dist/associations/owner-keys.d.ts +34 -0
  29. package/dist/associations/separate-include-loader.d.ts +24 -0
  30. package/dist/associations/types.d.ts +139 -0
  31. package/dist/connection/after-connect-hook.d.ts +24 -0
  32. package/dist/connection/connect-hooks.d.ts +26 -0
  33. package/dist/connection/connection-config.d.ts +33 -0
  34. package/dist/connection/connection-manager.d.ts +65 -0
  35. package/dist/connection/connection-types.d.ts +21 -0
  36. package/dist/connection/copy-from-stdin.d.ts +52 -0
  37. package/dist/connection/copy-runner.d.ts +30 -0
  38. package/dist/connection/copy-to-stdout.d.ts +49 -0
  39. package/dist/connection/copy.d.ts +22 -0
  40. package/dist/connection/notifications.d.ts +28 -0
  41. package/dist/connection/options.d.ts +165 -0
  42. package/dist/connection/query-logger.d.ts +41 -0
  43. package/dist/connection/replica-router.d.ts +20 -0
  44. package/dist/connection/statement-cache.d.ts +36 -0
  45. package/dist/connection/statement-timeout.d.ts +22 -0
  46. package/dist/data-types/abstract-data-type.d.ts +58 -0
  47. package/dist/data-types/array-literal-parser.d.ts +17 -0
  48. package/dist/data-types/array-type.d.ts +18 -0
  49. package/dist/data-types/bit-type.d.ts +14 -0
  50. package/dist/data-types/blob-type.d.ts +12 -0
  51. package/dist/data-types/char-type.d.ts +12 -0
  52. package/dist/data-types/composite-fields.d.ts +26 -0
  53. package/dist/data-types/composite-type.d.ts +32 -0
  54. package/dist/data-types/data-types.d.ts +176 -0
  55. package/dist/data-types/date-type.d.ts +14 -0
  56. package/dist/data-types/decimal-type.d.ts +13 -0
  57. package/dist/data-types/default-value-generator.d.ts +15 -0
  58. package/dist/data-types/enum-type.d.ts +19 -0
  59. package/dist/data-types/ewkb-reader.d.ts +18 -0
  60. package/dist/data-types/ewkb-writer.d.ts +17 -0
  61. package/dist/data-types/float-type.d.ts +12 -0
  62. package/dist/data-types/geometric-text.d.ts +65 -0
  63. package/dist/data-types/geometric-type.d.ts +46 -0
  64. package/dist/data-types/hstore-type.d.ts +16 -0
  65. package/dist/data-types/integer-type.d.ts +24 -0
  66. package/dist/data-types/json-type.d.ts +16 -0
  67. package/dist/data-types/multirange-type.d.ts +19 -0
  68. package/dist/data-types/range-type.d.ts +28 -0
  69. package/dist/data-types/record-text.d.ts +29 -0
  70. package/dist/data-types/scalar-type.d.ts +13 -0
  71. package/dist/data-types/spatial-type.d.ts +20 -0
  72. package/dist/data-types/string-type.d.ts +12 -0
  73. package/dist/data-types/text-type.d.ts +12 -0
  74. package/dist/data-types/timestamp-type.d.ts +15 -0
  75. package/dist/data-types/virtual-type.d.ts +15 -0
  76. package/dist/data-types/wall-clock.d.ts +14 -0
  77. package/dist/ddl/column-ddl.d.ts +73 -0
  78. package/dist/ddl/constraint-ddl.d.ts +30 -0
  79. package/dist/ddl/ddl-generator.d.ts +181 -0
  80. package/dist/ddl/ddl-guards.d.ts +60 -0
  81. package/dist/ddl/ddl-types.d.ts +204 -0
  82. package/dist/ddl/enum-ddl.d.ts +42 -0
  83. package/dist/ddl/extension-ddl.d.ts +57 -0
  84. package/dist/ddl/function-ddl.d.ts +98 -0
  85. package/dist/ddl/index-ddl.d.ts +29 -0
  86. package/dist/ddl/index-element-ddl.d.ts +19 -0
  87. package/dist/ddl/partition-ddl.d.ts +88 -0
  88. package/dist/ddl/partition-types.d.ts +94 -0
  89. package/dist/ddl/policy-ddl.d.ts +137 -0
  90. package/dist/ddl/routine-guards.d.ts +63 -0
  91. package/dist/ddl/sequence-ddl.d.ts +103 -0
  92. package/dist/ddl/sql-literal.d.ts +61 -0
  93. package/dist/ddl/table-ddl.d.ts +35 -0
  94. package/dist/ddl/trigger-ddl.d.ts +81 -0
  95. package/dist/ddl/view-ddl.d.ts +122 -0
  96. package/dist/decorators/association-applier.d.ts +18 -0
  97. package/dist/decorators/association-decorators.d.ts +72 -0
  98. package/dist/decorators/column-decorators.d.ts +147 -0
  99. package/dist/decorators/decorator-factory.d.ts +45 -0
  100. package/dist/decorators/decorator-signature.d.ts +26 -0
  101. package/dist/decorators/decorator-types.d.ts +24 -0
  102. package/dist/decorators/foreign-key-decorator.d.ts +21 -0
  103. package/dist/decorators/hook-decorators.d.ts +393 -0
  104. package/dist/decorators/init-arguments.d.ts +29 -0
  105. package/dist/decorators/model-decorators.d.ts +18 -0
  106. package/dist/decorators/model-metadata.d.ts +70 -0
  107. package/dist/decorators/table-decorators.d.ts +43 -0
  108. package/dist/decorators/timestamp-decorators.d.ts +38 -0
  109. package/dist/errors/base-error.d.ts +40 -0
  110. package/dist/errors/connection-errors.d.ts +152 -0
  111. package/dist/errors/database-errors.d.ts +186 -0
  112. package/dist/errors/errors.d.ts +5 -0
  113. package/dist/errors/map-pg-error.d.ts +27 -0
  114. package/dist/errors/misc-errors.d.ts +232 -0
  115. package/dist/errors/validation-errors.d.ts +141 -0
  116. package/dist/exports-associations.d.ts +6 -0
  117. package/dist/exports-core.d.ts +95 -0
  118. package/dist/exports-decorators.d.ts +8 -0
  119. package/dist/exports-errors.d.ts +2 -0
  120. package/dist/exports-model.d.ts +21 -0
  121. package/dist/exports-schema.d.ts +19 -0
  122. package/dist/expressions/call-expressions.d.ts +54 -0
  123. package/dist/expressions/condition-expressions.d.ts +51 -0
  124. package/dist/expressions/expression.d.ts +52 -0
  125. package/dist/expressions/jsonpath-helpers.d.ts +37 -0
  126. package/dist/expressions/logic.d.ts +25 -0
  127. package/dist/expressions/methods.d.ts +188 -0
  128. package/dist/expressions/op.d.ts +182 -0
  129. package/dist/expressions/query-expressions.d.ts +110 -0
  130. package/dist/expressions/row-expressions.d.ts +35 -0
  131. package/dist/expressions/search-helpers.d.ts +138 -0
  132. package/dist/expressions/trigram-helpers.d.ts +40 -0
  133. package/dist/hooks/hooks.d.ts +125 -0
  134. package/dist/index.cjs +21864 -0
  135. package/dist/index.cjs.map +1 -0
  136. package/dist/index.d.ts +6 -0
  137. package/dist/index.js +21688 -0
  138. package/dist/index.js.map +1 -0
  139. package/dist/model/attribute-columns.d.ts +85 -0
  140. package/dist/model/attribute-normalizer.d.ts +42 -0
  141. package/dist/model/attribute-options.d.ts +121 -0
  142. package/dist/model/bulk-insert-builder.d.ts +24 -0
  143. package/dist/model/bulk-options.d.ts +173 -0
  144. package/dist/model/copy-options.d.ts +51 -0
  145. package/dist/model/cte-builder.d.ts +134 -0
  146. package/dist/model/definition-normalizer.d.ts +26 -0
  147. package/dist/model/delete-query-builder.d.ts +42 -0
  148. package/dist/model/find-options.d.ts +144 -0
  149. package/dist/model/find-query-builder.d.ts +38 -0
  150. package/dist/model/inflector.d.ts +28 -0
  151. package/dist/model/insert-query-builder.d.ts +41 -0
  152. package/dist/model/instance-destroyer.d.ts +44 -0
  153. package/dist/model/instance-lifecycle-services.d.ts +61 -0
  154. package/dist/model/instance-lifecycle.d.ts +128 -0
  155. package/dist/model/instance-saver.d.ts +25 -0
  156. package/dist/model/instance-state.d.ts +48 -0
  157. package/dist/model/instance-validation.d.ts +35 -0
  158. package/dist/model/instance-values.d.ts +88 -0
  159. package/dist/model/instance-writer.d.ts +59 -0
  160. package/dist/model/join-source-builder.d.ts +25 -0
  161. package/dist/model/lateral-keys-builder.d.ts +25 -0
  162. package/dist/model/merge-action-builder.d.ts +31 -0
  163. package/dist/model/merge-options.d.ts +72 -0
  164. package/dist/model/merge-query-builder.d.ts +29 -0
  165. package/dist/model/merge-source-builder.d.ts +22 -0
  166. package/dist/model/mixins/model-aggregates.d.ts +69 -0
  167. package/dist/model/mixins/model-associations.d.ts +113 -0
  168. package/dist/model/mixins/model-constructor.d.ts +7 -0
  169. package/dist/model/mixins/model-finders.d.ts +140 -0
  170. package/dist/model/mixins/model-hooks.d.ts +142 -0
  171. package/dist/model/mixins/model-postgres.d.ts +198 -0
  172. package/dist/model/mixins/model-schema-binding.d.ts +36 -0
  173. package/dist/model/mixins/model-schema.d.ts +100 -0
  174. package/dist/model/mixins/model-scopes.d.ts +57 -0
  175. package/dist/model/mixins/model-writers.d.ts +175 -0
  176. package/dist/model/mixins/named-hooks.d.ts +28 -0
  177. package/dist/model/model-accessors.d.ts +22 -0
  178. package/dist/model/model-base.d.ts +83 -0
  179. package/dist/model/model-definition.d.ts +130 -0
  180. package/dist/model/model-instance-persistence.d.ts +132 -0
  181. package/dist/model/model-instance-values.d.ts +197 -0
  182. package/dist/model/model-operations.d.ts +22 -0
  183. package/dist/model/model-registry.d.ts +152 -0
  184. package/dist/model/model-services.d.ts +46 -0
  185. package/dist/model/model-state.d.ts +68 -0
  186. package/dist/model/model-values.d.ts +86 -0
  187. package/dist/model/model.d.ts +629 -0
  188. package/dist/model/on-conflict-builder.d.ts +111 -0
  189. package/dist/model/operations/bulk-create-operation.d.ts +40 -0
  190. package/dist/model/operations/copy-from-source.d.ts +51 -0
  191. package/dist/model/operations/copy-operation.d.ts +54 -0
  192. package/dist/model/operations/count-operation.d.ts +52 -0
  193. package/dist/model/operations/create-operation.d.ts +31 -0
  194. package/dist/model/operations/destroy-operation.d.ts +65 -0
  195. package/dist/model/operations/find-cursor.d.ts +23 -0
  196. package/dist/model/operations/find-lookups.d.ts +99 -0
  197. package/dist/model/operations/find-operation.d.ts +47 -0
  198. package/dist/model/operations/increment-operation.d.ts +40 -0
  199. package/dist/model/operations/insert-operation.d.ts +71 -0
  200. package/dist/model/operations/merge-operation.d.ts +56 -0
  201. package/dist/model/operations/model-operation.d.ts +33 -0
  202. package/dist/model/operations/update-operation.d.ts +45 -0
  203. package/dist/model/operations/upsert-operation.d.ts +39 -0
  204. package/dist/model/options.d.ts +103 -0
  205. package/dist/model/returning-old.d.ts +52 -0
  206. package/dist/model/row-mapper.d.ts +78 -0
  207. package/dist/model/row-plan.d.ts +31 -0
  208. package/dist/model/runtime.d.ts +56 -0
  209. package/dist/model/scope-registry.d.ts +81 -0
  210. package/dist/model/select-aggregates.d.ts +37 -0
  211. package/dist/model/select-lock.d.ts +13 -0
  212. package/dist/model/select-options.d.ts +92 -0
  213. package/dist/model/select-query-builder.d.ts +73 -0
  214. package/dist/model/select-targets.d.ts +77 -0
  215. package/dist/model/source-option-builder.d.ts +23 -0
  216. package/dist/model/source-options.d.ts +108 -0
  217. package/dist/model/statement-builder.d.ts +77 -0
  218. package/dist/model/statement-services.d.ts +2 -0
  219. package/dist/model/sync-hooks.d.ts +18 -0
  220. package/dist/model/table-sample-builder.d.ts +13 -0
  221. package/dist/model/types.d.ts +85 -0
  222. package/dist/model/unnest-insert-builder.d.ts +24 -0
  223. package/dist/model/update-query-builder.d.ts +39 -0
  224. package/dist/model/v6-conflict-builder.d.ts +37 -0
  225. package/dist/model/value-cloner.d.ts +17 -0
  226. package/dist/model/values-writer.d.ts +12 -0
  227. package/dist/model/where-options.d.ts +164 -0
  228. package/dist/model/write-options.d.ts +160 -0
  229. package/dist/model/written-rows.d.ts +56 -0
  230. package/dist/package-version.d.ts +8 -0
  231. package/dist/query/query-result-shaper.d.ts +93 -0
  232. package/dist/query/raw-query.d.ts +27 -0
  233. package/dist/query-interface/alter-planner.d.ts +40 -0
  234. package/dist/query-interface/bulk-data.d.ts +44 -0
  235. package/dist/query-interface/column-commands.d.ts +52 -0
  236. package/dist/query-interface/column-describer.d.ts +17 -0
  237. package/dist/query-interface/enum-commands.d.ts +36 -0
  238. package/dist/query-interface/index-commands.d.ts +57 -0
  239. package/dist/query-interface/model-tables.d.ts +58 -0
  240. package/dist/query-interface/object-commands.d.ts +71 -0
  241. package/dist/query-interface/partition-commands.d.ts +43 -0
  242. package/dist/query-interface/policy-commands.d.ts +54 -0
  243. package/dist/query-interface/query-interface-catalog.d.ts +180 -0
  244. package/dist/query-interface/query-interface-objects.d.ts +108 -0
  245. package/dist/query-interface/query-interface-partitions.d.ts +66 -0
  246. package/dist/query-interface/query-interface-policies.d.ts +86 -0
  247. package/dist/query-interface/query-interface-routines.d.ts +120 -0
  248. package/dist/query-interface/query-interface-tables.d.ts +179 -0
  249. package/dist/query-interface/query-interface-types.d.ts +62 -0
  250. package/dist/query-interface/query-interface-views.d.ts +84 -0
  251. package/dist/query-interface/query-interface.d.ts +256 -0
  252. package/dist/query-interface/routine-commands.d.ts +71 -0
  253. package/dist/query-interface/schema-synchronizer.d.ts +110 -0
  254. package/dist/query-interface/statement-runner.d.ts +40 -0
  255. package/dist/query-interface/sync-planner.d.ts +26 -0
  256. package/dist/query-interface/table-commands.d.ts +63 -0
  257. package/dist/query-interface/table-introspector.d.ts +58 -0
  258. package/dist/query-interface/view-commands.d.ts +47 -0
  259. package/dist/sequelize/instance-hook-adders.d.ts +72 -0
  260. package/dist/sequelize/sequelize-base.d.ts +196 -0
  261. package/dist/sequelize/sequelize-constructor.d.ts +7 -0
  262. package/dist/sequelize/sequelize-helpers.d.ts +133 -0
  263. package/dist/sequelize/sequelize-hooks.d.ts +99 -0
  264. package/dist/sequelize/sequelize-internals.d.ts +87 -0
  265. package/dist/sequelize/sequelize-notifications.d.ts +66 -0
  266. package/dist/sequelize/sequelize-schema.d.ts +125 -0
  267. package/dist/sequelize/sequelize-transactions.d.ts +96 -0
  268. package/dist/sequelize.d.ts +1175 -0
  269. package/dist/sql/ast-clauses.d.ts +137 -0
  270. package/dist/sql/ast-expressions.d.ts +88 -0
  271. package/dist/sql/ast-statements.d.ts +80 -0
  272. package/dist/sql/ast.d.ts +21 -0
  273. package/dist/sql/compile.d.ts +21 -0
  274. package/dist/sql/dml-compiler.d.ts +54 -0
  275. package/dist/sql/expression-compiler.d.ts +56 -0
  276. package/dist/sql/from-compiler.d.ts +39 -0
  277. package/dist/sql/identifier-quoter.d.ts +15 -0
  278. package/dist/sql/merge-compiler.d.ts +20 -0
  279. package/dist/sql/order.d.ts +15 -0
  280. package/dist/sql/query-compiler.d.ts +45 -0
  281. package/dist/sql/sql-chunks.d.ts +50 -0
  282. package/dist/sql/with-compiler.d.ts +19 -0
  283. package/dist/transaction/advisory-locks.d.ts +28 -0
  284. package/dist/transaction/cls-namespace.d.ts +44 -0
  285. package/dist/transaction/transaction-constants.d.ts +35 -0
  286. package/dist/transaction/transaction-runner.d.ts +78 -0
  287. package/dist/transaction/transaction-starter.d.ts +25 -0
  288. package/dist/transaction/transaction-statements.d.ts +29 -0
  289. package/dist/transaction/transaction.d.ts +201 -0
  290. package/dist/validation/attribute-validators.d.ts +23 -0
  291. package/dist/validation/builtin-attribute-validator.d.ts +19 -0
  292. package/dist/validation/builtin-validators.d.ts +16 -0
  293. package/dist/validation/core-validator.d.ts +16 -0
  294. package/dist/validation/custom-validators.d.ts +13 -0
  295. package/dist/validation/instance-validator.d.ts +25 -0
  296. package/dist/validation/schema-items.d.ts +22 -0
  297. package/dist/validation/standard-schema-validator.d.ts +30 -0
  298. package/dist/validation/standard-schema.d.ts +39 -0
  299. package/dist/validation/types.d.ts +36 -0
  300. package/dist/validation/validation-target.d.ts +13 -0
  301. package/dist/where/comparison-compiler.d.ts +27 -0
  302. package/dist/where/condition-compiler.d.ts +18 -0
  303. package/dist/where/operand-resolver.d.ts +10 -0
  304. package/dist/where/operator-allowlist.d.ts +14 -0
  305. package/dist/where/where-support.d.ts +52 -0
  306. package/dist/where/where.d.ts +46 -0
  307. package/dist/where/window-compiler.d.ts +14 -0
  308. package/llm/USAGE.md +423 -0
  309. package/package.json +103 -4
  310. package/skills/postgrelize/SKILL.md +57 -0
  311. package/skills/postgrelize/reference/associations.md +108 -0
  312. package/skills/postgrelize/reference/errors.md +37 -0
  313. package/skills/postgrelize/reference/migrating-from-sequelize.md +15 -0
  314. package/skills/postgrelize/reference/postgresql-features.md +157 -0
  315. package/skills/postgrelize/reference/querying.md +111 -0
  316. package/skills/postgrelize/reference/schema.md +135 -0
  317. package/skills/postgrelize/reference/security.md +34 -0
  318. package/skills/postgrelize/reference/transactions-and-sessions.md +122 -0
  319. package/skills/postgrelize/reference/writing.md +198 -0
@@ -0,0 +1,175 @@
1
+ import { AnyModel, AttributeAmounts, Attributes, BuildOptions, BulkCreateOptions, CreateOptions, CreationAttributes, DestroyOptions, IncrementOptions, ModelStatic, RestoreOptions, UpdateOptions, UpsertOptions, Values } from '../options.ts';
2
+ import { ModelConstructor } from './model-constructor.ts';
3
+ /**
4
+ * Write statics of `Model`: `build`, `bulkBuild`, `create`, `bulkCreate`, `upsert`, `update`, `destroy`, `restore`, `increment`, `decrement`.
5
+ *
6
+ * @internal
7
+ */
8
+ export declare const ModelWriters: <TBase extends ModelConstructor>(Base: TBase) => {
9
+ new (...args: any[]): {
10
+ get wasInserted(): boolean | undefined;
11
+ get oldValues(): Readonly<Record<string, unknown>> | null | undefined;
12
+ get sequelize(): import('../runtime.ts').RuntimeOwner;
13
+ };
14
+ /**
15
+ * Builds a new instance in memory without touching the database; call `save()` to insert it.
16
+ * Defaults and custom setters are applied.
17
+ *
18
+ * @param this - The model class.
19
+ * @param values - Attribute values.
20
+ * @param options - Build options.
21
+ * @returns New instance.
22
+ * @example
23
+ * ```ts
24
+ * const user = User.build({ email: 'ada@example.com' });
25
+ * await user.save();
26
+ * ```
27
+ */
28
+ build<M extends AnyModel>(this: ModelStatic<M>, values?: CreationAttributes<M> | Values, options?: BuildOptions): M;
29
+ /**
30
+ * Builds several new instances in memory, same as calling {@link Model.build} for each record.
31
+ *
32
+ * @param this - The model class.
33
+ * @param records - Attribute values per instance.
34
+ * @param options - Build options.
35
+ * @returns New instances.
36
+ * @example
37
+ * ```ts
38
+ * const tags = Tag.bulkBuild([{ name: 'news' }, { name: 'sports' }]);
39
+ * ```
40
+ */
41
+ bulkBuild<M extends AnyModel>(this: ModelStatic<M>, records: readonly (CreationAttributes<M> | Values)[], options?: BuildOptions): M[];
42
+ /**
43
+ * Builds an instance and inserts it with `INSERT ... RETURNING`, running validation and the
44
+ * create/save hooks. With `onConflict` (PostgreSQL extension) the insert may be skipped or turned
45
+ * into an update, and `instance.wasInserted` tells which happened.
46
+ *
47
+ * @param this - The model class.
48
+ * @param values - Attribute values.
49
+ * @param options - Create options (`fields`, `hooks`, `validate`, `include`, `onConflict`, query options).
50
+ * @returns Saved instance.
51
+ * @throws ValidationError when validation fails.
52
+ * @throws UniqueConstraintError when a unique constraint is violated.
53
+ * @throws ForeignKeyConstraintError when a foreign key constraint is violated.
54
+ * @throws DatabaseError for other database errors.
55
+ * @example
56
+ * ```ts
57
+ * const user = await User.create({ email: 'ada@example.com' }, { transaction });
58
+ * ```
59
+ */
60
+ create<M extends AnyModel>(this: ModelStatic<M>, values?: CreationAttributes<M>, options?: CreateOptions<Attributes<M>>): Promise<M>;
61
+ /**
62
+ * Inserts many rows with one multi-row `INSERT ... RETURNING`. Runs `beforeBulkCreate` and
63
+ * `afterBulkCreate` hooks; rows are not validated unless `validate: true`. `ignoreDuplicates`,
64
+ * `updateOnDuplicate` and `onConflict` map to `ON CONFLICT`; `individualHooks` or `include`
65
+ * insert row by row like Sequelize v6.
66
+ *
67
+ * @param this - The model class.
68
+ * @param records - Attribute values per row.
69
+ * @param options - Bulk create options.
70
+ * @returns Instances with values returned by the database.
71
+ * @throws ValidationError with `validate: true` when a row is invalid.
72
+ * @throws UniqueConstraintError when a unique constraint is violated and no conflict handling is set.
73
+ * @example
74
+ * ```ts
75
+ * const tags = await Tag.bulkCreate([{ name: 'news' }, { name: 'sports' }], { ignoreDuplicates: true });
76
+ * ```
77
+ * @see {@link Model.insert} for the PostgreSQL variant that returns only the rows actually written.
78
+ */
79
+ bulkCreate<M extends AnyModel>(this: ModelStatic<M>, records: readonly CreationAttributes<M>[], options?: BulkCreateOptions<Attributes<M>>): Promise<M[]>;
80
+ /**
81
+ * Inserts a row, or updates it when it conflicts with a unique key (`INSERT ... ON CONFLICT DO UPDATE`,
82
+ * Sequelize v6 `upsert`). Runs the `beforeUpsert` and `afterUpsert` hooks.
83
+ *
84
+ * @param this - The model class.
85
+ * @param values - Attribute values.
86
+ * @param options - Upsert options (`conflictFields`, `fields`, `onConflict`, query options).
87
+ * @returns `[instance, null]` like Sequelize v6, or `[instance, created]` with `onConflict`.
88
+ * @throws ValidationError when validation fails.
89
+ * @throws UniqueConstraintError when a unique constraint other than the conflict target is violated.
90
+ * @example
91
+ * ```ts
92
+ * const [user] = await User.upsert({ email: 'ada@example.com', name: 'Ada' }, { conflictFields: ['email'] });
93
+ * ```
94
+ */
95
+ upsert<M extends AnyModel>(this: ModelStatic<M>, values: CreationAttributes<M>, options?: UpsertOptions<Attributes<M>>): Promise<[M, boolean | null]>;
96
+ /**
97
+ * Updates all rows matching `where` with one `UPDATE` and refreshes `updatedAt` unless `silent`.
98
+ * Values are validated unless `validate: false`; bulk hooks run unless `hooks: false`.
99
+ *
100
+ * @param this - The model class.
101
+ * @param values - New attribute values.
102
+ * @param options - Update options; `where` is required.
103
+ * @returns `[affectedCount]`, or `[affectedCount, rows]` with `returning: true`.
104
+ * @throws ValidationError when the new values are invalid.
105
+ * @example
106
+ * ```ts
107
+ * const [count] = await Post.update({ published: true }, { where: { userId: 1 } });
108
+ * ```
109
+ */
110
+ update<M extends AnyModel>(this: ModelStatic<M>, values: Partial<Attributes<M>>, options: UpdateOptions<Attributes<M>>): Promise<[affectedCount: number, affectedRows?: M[]]>;
111
+ /**
112
+ * Deletes rows matching `where` and returns the deleted instances (`DELETE ... RETURNING`, a
113
+ * PostgreSQL extension). For paranoid models the rows are soft-deleted unless `force: true`.
114
+ *
115
+ * @param this - The model class.
116
+ * @param options - Destroy options with `returning: true`.
117
+ * @returns Deleted instances.
118
+ * @example
119
+ * ```ts
120
+ * const removed = await Post.destroy({ where: { published: false }, returning: true });
121
+ * ```
122
+ */
123
+ destroy<M extends AnyModel>(this: ModelStatic<M>, options: DestroyOptions<Attributes<M>> & Readonly<{
124
+ returning: true;
125
+ }>): Promise<M[]>;
126
+ /**
127
+ * Deletes rows matching `where` (`truncate: true` empties the table instead). For paranoid models
128
+ * the rows are soft-deleted (`deletedAt` is set) unless `force: true`. Runs bulk destroy hooks
129
+ * unless `hooks: false`.
130
+ *
131
+ * @param this - The model class.
132
+ * @param options - Destroy options.
133
+ * @returns Number of deleted rows.
134
+ */
135
+ destroy<M extends AnyModel>(this: ModelStatic<M>, options?: DestroyOptions<Attributes<M>>): Promise<number>;
136
+ /**
137
+ * Restores soft-deleted rows of a paranoid model by setting `deletedAt` back to `NULL`.
138
+ *
139
+ * @param this - The model class.
140
+ * @param options - Rows to restore and hook options.
141
+ * @returns Resolves when done.
142
+ * @throws Error when the model is not paranoid.
143
+ * @example
144
+ * ```ts
145
+ * await Post.restore({ where: { userId: 1 } });
146
+ * ```
147
+ */
148
+ restore<M extends AnyModel>(this: ModelStatic<M>, options?: RestoreOptions<Attributes<M>>): Promise<void>;
149
+ /**
150
+ * Atomically increments numeric attributes of the rows matching `where` (`SET x = x + by`).
151
+ *
152
+ * @param this - The model class.
153
+ * @param fields - Attribute name(s), or a map of attribute to amount.
154
+ * @param options - Increment options (`where`, `by` default 1, `silent`, query options).
155
+ * @returns `[affectedRows, affectedCount]`: the updated instances and their number.
156
+ * @example
157
+ * ```ts
158
+ * await Post.increment('views', { by: 1, where: { id: 5 } });
159
+ * ```
160
+ */
161
+ increment<M extends AnyModel>(this: ModelStatic<M>, fields: AttributeAmounts<Attributes<M>>, options?: IncrementOptions<Attributes<M>>): Promise<[affectedRows: M[], affectedCount: number]>;
162
+ /**
163
+ * Atomically decrements numeric attributes of the rows matching `where` (`SET x = x - by`).
164
+ *
165
+ * @param this - The model class.
166
+ * @param fields - Attribute name(s), or a map of attribute to amount.
167
+ * @param options - Decrement options (`where`, `by` default 1, `silent`, query options).
168
+ * @returns `[affectedRows, affectedCount]`: the updated instances and their number.
169
+ * @example
170
+ * ```ts
171
+ * await Product.decrement({ stock: 3 }, { where: { id: 7 } });
172
+ * ```
173
+ */
174
+ decrement<M extends AnyModel>(this: ModelStatic<M>, fields: AttributeAmounts<Attributes<M>>, options?: IncrementOptions<Attributes<M>>): Promise<[affectedRows: M[], affectedCount: number]>;
175
+ } & TBase;
@@ -0,0 +1,28 @@
1
+ import { HookFunction } from '../../hooks/hooks.ts';
2
+ /**
3
+ * Named hook method of a model class, e.g. `Model.beforeCreate`: registers a hook function, optionally under a name that
4
+ * {@link Model.removeHook} can use later.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * User.beforeCreate(async (instance: User) => {
9
+ * instance.set('email', String(instance.get('email')).trim());
10
+ * });
11
+ * User.afterCreate('audit', async (instance: User) => {
12
+ * console.log('created', instance.get('id'));
13
+ * });
14
+ * ```
15
+ */
16
+ export type NamedHookAdder = {
17
+ /**
18
+ * @param fn - Hook function.
19
+ */
20
+ (fn: HookFunction): void;
21
+ /**
22
+ * @param name - Hook name, used to remove it later.
23
+ * @param fn - Hook function.
24
+ */
25
+ (name: string, fn: HookFunction): void;
26
+ };
27
+ /** @internal Hook types that get a named adder method on model classes. */
28
+ export declare const NAMED_HOOKS: readonly ["beforeValidate", "afterValidate", "validationFailed", "beforeCreate", "afterCreate", "beforeUpdate", "afterUpdate", "beforeSave", "afterSave", "beforeDestroy", "afterDestroy", "beforeRestore", "afterRestore", "beforeUpsert", "afterUpsert", "beforeBulkCreate", "afterBulkCreate", "beforeBulkUpdate", "afterBulkUpdate", "beforeBulkDestroy", "afterBulkDestroy", "beforeBulkRestore", "afterBulkRestore", "beforeFind", "beforeFindAfterExpandIncludeAll", "beforeFindAfterOptions", "afterFind", "beforeCount", "beforeSync", "afterSync"];
@@ -0,0 +1,22 @@
1
+ import { ModelDefinition } from './model-definition.ts';
2
+ /**
3
+ * Installs `instance.<attribute>` and `instance.<alias>` accessors on model prototypes.
4
+ *
5
+ * @internal
6
+ */
7
+ export declare class ModelAccessors {
8
+ /**
9
+ * Defines `instance.<attribute>` getters / setters on the model prototype (once per attribute).
10
+ *
11
+ * @param prototype - Model prototype.
12
+ * @param definition - Model definition.
13
+ */
14
+ defineAttributes(prototype: object, definition: ModelDefinition): void;
15
+ /**
16
+ * Defines `instance.<alias>` for an association, holding included / nested instances.
17
+ *
18
+ * @param prototype - Model prototype.
19
+ * @param alias - Association alias.
20
+ */
21
+ defineAssociation(prototype: object, alias: string): void;
22
+ }
@@ -0,0 +1,83 @@
1
+ import { AttributeDefinition, DefinitionOptions, ModelAttributes } from './model-definition.ts';
2
+ import { AnyModel, BuildOptions, InitOptions, ModelStatic, QualifiedTableName, Values } from './options.ts';
3
+ import { RuntimeOwner } from './runtime.ts';
4
+ /**
5
+ * Core of every model: instance state, model metadata and `init`. Capabilities are added by the
6
+ * model mixins; `Model` is the public class.
7
+ *
8
+ * @internal
9
+ */
10
+ export declare class ModelBase {
11
+ /**
12
+ * @param values - Attribute values.
13
+ * @param options - Build options.
14
+ */
15
+ constructor(values?: Values, options?: BuildOptions);
16
+ /**
17
+ * For instances returned by `insert`, `create` / `bulkCreate` / `upsert` with `onConflict`:
18
+ * true when the row was inserted, false when an existing row was updated (or nothing was
19
+ * written). `undefined` otherwise. PostgreSQL extension.
20
+ */
21
+ get wasInserted(): boolean | undefined;
22
+ /**
23
+ * For instances returned with `returningOld: true`: attribute values of the row before the
24
+ * statement, or `null` when the row did not exist (inserted). `undefined` otherwise. PostgreSQL 18+.
25
+ */
26
+ get oldValues(): Readonly<Record<string, unknown>> | null | undefined;
27
+ /** `Sequelize` instance the model belongs to. */
28
+ get sequelize(): RuntimeOwner;
29
+ /** Name the model was registered under, as given by `modelName` in the init options (default: the class name). */
30
+ static get modelName(): string;
31
+ /** Name of the database table backing the model (pluralized model name unless `tableName` was set). */
32
+ static get tableName(): string;
33
+ /** Normalized attributes keyed by attribute name. */
34
+ static get rawAttributes(): Readonly<Record<string, AttributeDefinition>>;
35
+ /** First primary key attribute name. */
36
+ static get primaryKeyAttribute(): string | undefined;
37
+ /** All primary key attribute names. */
38
+ static get primaryKeyAttributes(): readonly string[];
39
+ /** Model options after defaults were applied. */
40
+ static get options(): DefinitionOptions;
41
+ /** `Sequelize` instance the model belongs to. */
42
+ static get sequelize(): RuntimeOwner;
43
+ /**
44
+ * Defines attributes and options of the model and registers it in `sequelize.models`. Does not
45
+ * touch the database; call {@link Model.sync} or run migrations to create the table.
46
+ *
47
+ * @param this - The model class being initialized.
48
+ * @param attributes - Attribute definitions.
49
+ * @param options - Model options, including the `sequelize` instance.
50
+ * @returns The model class.
51
+ * @example
52
+ * ```ts
53
+ * class Project extends Model {}
54
+ * Project.init(
55
+ * { id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true }, name: DataTypes.STRING },
56
+ * { sequelize, modelName: 'Project', paranoid: true },
57
+ * );
58
+ * ```
59
+ */
60
+ static init<MS extends ModelStatic<AnyModel>>(this: MS, attributes: ModelAttributes, options: InitOptions): MS;
61
+ /**
62
+ * Returns the normalized attribute definitions, same as {@link Model.rawAttributes}.
63
+ *
64
+ * @returns Attribute definitions.
65
+ * @example
66
+ * ```ts
67
+ * const attributes = User.getAttributes();
68
+ * Object.keys(attributes);
69
+ * ```
70
+ */
71
+ static getAttributes(): Readonly<Record<string, AttributeDefinition>>;
72
+ /**
73
+ * Table name, or the qualified table (`{ tableName, schema, delimiter, ... }`, like v6) when the
74
+ * model has a schema. `String(qualified)` is the quoted `"schema"."table"` reference.
75
+ *
76
+ * @returns Table name or qualified table.
77
+ * @example
78
+ * ```ts
79
+ * const table = User.getTableName();
80
+ * ```
81
+ */
82
+ static getTableName(): string | QualifiedTableName;
83
+ }
@@ -0,0 +1,130 @@
1
+ import { ModelDefaults } from '../connection/options.ts';
2
+ import { DataTypeInput } from '../data-types/data-types.ts';
3
+ import { IndexOptions } from '../ddl/ddl-generator.ts';
4
+ import { AttributeDefinition, AttributeOptions, ModelAttributes } from './attribute-options.ts';
5
+ export type { AttributeDefinition, AttributeOptions, GeneratedColumn, ModelAttributes, ReferencedTable, ReferenceOptions, UniqueOptions, } from './attribute-options.ts';
6
+ /**
7
+ * Table-level model options shared by `Model.init` and `sequelize.define`.
8
+ *
9
+ * Extends the model defaults (`paranoid`, `timestamps`, `schema`, ...).
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const opts: DefinitionOptions = {
14
+ * modelName: 'Invoice',
15
+ * tableName: 'invoices',
16
+ * timestamps: true,
17
+ * paranoid: true,
18
+ * version: true,
19
+ * indexes: [{ fields: ['number'], unique: true }],
20
+ * };
21
+ * ```
22
+ */
23
+ export type DefinitionOptions = ModelDefaults & Readonly<{
24
+ /** Model name. Defaults to the class name. */
25
+ modelName?: string;
26
+ /** Table name. Defaults to the pluralized model name. */
27
+ tableName?: string;
28
+ /** Separator between schema and table that `getTableName` reports (PostgreSQL always uses `.` in SQL). */
29
+ schemaDelimiter?: string;
30
+ /** Name of the created-at attribute, or `false` to disable it.
31
+ * @defaultValue 'createdAt' */
32
+ createdAt?: string | boolean;
33
+ /** Name of the updated-at attribute, or `false` to disable it.
34
+ * @defaultValue 'updatedAt' */
35
+ updatedAt?: string | boolean;
36
+ /** Name of the deleted-at attribute of paranoid models.
37
+ * @defaultValue 'deletedAt' */
38
+ deletedAt?: string | boolean;
39
+ /** Optimistic locking: `true` adds a `version` attribute, a string names it. */
40
+ version?: boolean | string;
41
+ /** Indexes created by `sync()`. */
42
+ indexes?: readonly IndexOptions[];
43
+ /** Table comment. */
44
+ comment?: string;
45
+ /** `CREATE UNLOGGED TABLE` on `sync`: faster writes, no WAL, emptied after a crash, not replicated. */
46
+ unlogged?: boolean;
47
+ /** `CREATE TEMPORARY TABLE` on `sync`: lives as long as the database session; cannot have a `schema`. See {@link QueryInterface.createTable}. */
48
+ temporary?: boolean;
49
+ }>;
50
+ /** Normalized fields of a {@link ModelDefinition}. */
51
+ export type ModelDefinitionFields = Readonly<{
52
+ /** Model name. */
53
+ name: string;
54
+ /** Table name. */
55
+ tableName: string;
56
+ /** Table schema. */
57
+ schema: string | undefined;
58
+ /** Normalized attributes by attribute name. */
59
+ attributes: ReadonlyMap<string, AttributeDefinition>;
60
+ /** Attribute name by column name. */
61
+ fieldToAttribute: ReadonlyMap<string, string>;
62
+ /** Primary key attribute names. */
63
+ primaryKeys: readonly string[];
64
+ /** Created-at attribute. */
65
+ createdAt: string | undefined;
66
+ /** Updated-at attribute. */
67
+ updatedAt: string | undefined;
68
+ /** Deleted-at attribute when the model is paranoid. */
69
+ deletedAt: string | undefined;
70
+ /** Version attribute when optimistic locking is enabled. */
71
+ version: string | undefined;
72
+ /** Unique keys from attribute `unique` options: key name → attribute names (in definition order). */
73
+ uniqueKeys: ReadonlyMap<string, readonly string[]>;
74
+ /** Model options after defaults were applied. */
75
+ options: DefinitionOptions;
76
+ }>;
77
+ /**
78
+ * Immutable normalized model definition: table, attributes, keys, timestamps and options of a
79
+ * model, built from `Model.init` arguments with Sequelize v6 defaults by {@link ModelDefinition.normalize}.
80
+ */
81
+ export declare class ModelDefinition {
82
+ /** Model name. */
83
+ readonly name: string;
84
+ /** Table name. */
85
+ readonly tableName: string;
86
+ /** Table schema. */
87
+ readonly schema: string | undefined;
88
+ /** Normalized attributes by attribute name. */
89
+ readonly attributes: ReadonlyMap<string, AttributeDefinition>;
90
+ /** Attribute name by column name. */
91
+ readonly fieldToAttribute: ReadonlyMap<string, string>;
92
+ /** Primary key attribute names. */
93
+ readonly primaryKeys: readonly string[];
94
+ /** Created-at attribute. */
95
+ readonly createdAt: string | undefined;
96
+ /** Updated-at attribute. */
97
+ readonly updatedAt: string | undefined;
98
+ /** Deleted-at attribute when the model is paranoid. */
99
+ readonly deletedAt: string | undefined;
100
+ /** Version attribute when optimistic locking is enabled. */
101
+ readonly version: string | undefined;
102
+ /** Unique keys from attribute `unique` options: key name → attribute names (in definition order). */
103
+ readonly uniqueKeys: ReadonlyMap<string, readonly string[]>;
104
+ /** Model options after defaults were applied. */
105
+ readonly options: DefinitionOptions;
106
+ /**
107
+ * @param fields - Normalized fields; the instance is frozen.
108
+ */
109
+ constructor(fields: ModelDefinitionFields);
110
+ /**
111
+ * Normalizes one attribute: column name, data type instance, `allowNull` default.
112
+ *
113
+ * @param name - Attribute name.
114
+ * @param input - Data type or column options.
115
+ * @param underscored - Derive the column name in snake case.
116
+ * @returns Frozen attribute definition.
117
+ */
118
+ static attribute(name: string, input: DataTypeInput | AttributeOptions, underscored: boolean): AttributeDefinition;
119
+ /**
120
+ * Normalizes `Model.init` arguments into an immutable definition, applying Sequelize v6 defaults.
121
+ *
122
+ * @param className - Class name (default model name).
123
+ * @param attributes - Declared attributes.
124
+ * @param options - Model options.
125
+ * @param defaults - `define` defaults of the Sequelize instance.
126
+ * @param associationAttributes - Attributes added by associations (foreign keys).
127
+ * @returns The definition.
128
+ */
129
+ static normalize(className: string, attributes: ModelAttributes, options: DefinitionOptions, defaults?: ModelDefaults, associationAttributes?: ModelAttributes): ModelDefinition;
130
+ }
@@ -0,0 +1,132 @@
1
+ import { ValidateOptions } from './instance-lifecycle.ts';
2
+ import { AttributeAmounts, IncrementOptions, InstanceDestroyOptions, SaveOptions, Values } from './options.ts';
3
+ import { QueryOptionsBase } from './runtime.ts';
4
+ /**
5
+ * Persistence of model instances: `save`, `validate`, `update`, `reload`, `destroy`, `restore`, `isSoftDeleted`, `increment`, `decrement`.
6
+ *
7
+ * @internal
8
+ */
9
+ export declare class ModelInstancePersistence<TAttributes extends object = Values> {
10
+ /** Current attribute values. */
11
+ dataValues: TAttributes;
12
+ /**
13
+ * Inserts the instance when it is new, otherwise updates its changed attributes. Runs validation
14
+ * and the `beforeValidate`/`afterValidate`, `beforeSave`/`afterSave` and `beforeCreate`/`beforeUpdate`
15
+ * (and `after*`) hooks unless disabled in the options; updating an unchanged instance sends no query.
16
+ *
17
+ * @param options - Save options.
18
+ * @returns This instance with values returned by the database.
19
+ * @throws ValidationError when validation fails.
20
+ * @throws UniqueConstraintError when a unique constraint is violated.
21
+ * @throws ForeignKeyConstraintError when a foreign key constraint is violated.
22
+ * @example
23
+ * ```ts
24
+ * const user = User.build({ email: 'ada@example.com' });
25
+ * await user.save({ transaction });
26
+ * ```
27
+ */
28
+ save(options?: SaveOptions<TAttributes>): Promise<this>;
29
+ /**
30
+ * Runs the attribute validators and model validators without saving (Sequelize v6 `instance.validate()`).
31
+ *
32
+ * @param options - `hooks`, `skip`, `fields`.
33
+ * @returns Resolves when valid.
34
+ * @throws ValidationError with all failures.
35
+ * @example
36
+ * ```ts
37
+ * await user.validate();
38
+ * ```
39
+ */
40
+ validate(options?: ValidateOptions): Promise<void>;
41
+ /**
42
+ * Sets values and saves the instance, same as {@link Model.set} followed by {@link Model.save}.
43
+ *
44
+ * @param values - New values.
45
+ * @param options - Save options.
46
+ * @returns This instance.
47
+ * @throws ValidationError when validation fails.
48
+ * @example
49
+ * ```ts
50
+ * await user.update({ email: 'ada@example.com' });
51
+ * ```
52
+ */
53
+ update(values: Partial<TAttributes>, options?: SaveOptions<TAttributes>): Promise<this>;
54
+ /**
55
+ * Re-reads the row from the database and replaces the instance values, discarding unsaved changes.
56
+ *
57
+ * @param options - Query options.
58
+ * @returns This instance.
59
+ * @throws InstanceError when the row no longer exists.
60
+ * @example
61
+ * ```ts
62
+ * await user.reload({ transaction });
63
+ * ```
64
+ */
65
+ reload(options?: QueryOptionsBase): Promise<this>;
66
+ /**
67
+ * Deletes the row of this instance. For paranoid models it sets `deletedAt` instead, unless
68
+ * `force: true`. Runs `beforeDestroy`/`afterDestroy` hooks unless `hooks: false`.
69
+ *
70
+ * @param options - Destroy options (`force`, `hooks`, query options).
71
+ * @returns Resolves when deleted.
72
+ * @example
73
+ * ```ts
74
+ * await user.destroy();
75
+ * ```
76
+ */
77
+ destroy(options?: InstanceDestroyOptions): Promise<void>;
78
+ /**
79
+ * Clears `deletedAt` of this soft-deleted instance of a paranoid model.
80
+ *
81
+ * @param options - Query options; `hooks: false` skips restore hooks.
82
+ * @returns Resolves when restored.
83
+ * @throws Error when the model is not paranoid.
84
+ * @example
85
+ * ```ts
86
+ * await user.restore();
87
+ * ```
88
+ */
89
+ restore(options?: QueryOptionsBase & Readonly<{
90
+ hooks?: boolean;
91
+ }>): Promise<void>;
92
+ /**
93
+ * Whether this instance of a paranoid model is soft-deleted.
94
+ *
95
+ * @returns True when `deletedAt` is set.
96
+ * @throws Error when the model is not paranoid.
97
+ * @example
98
+ * ```ts
99
+ * if (user.isSoftDeleted()) {
100
+ * await user.restore();
101
+ * }
102
+ * ```
103
+ */
104
+ isSoftDeleted(): boolean;
105
+ /**
106
+ * Increments numeric attributes of this row in the database (`SET x = x + by`). The instance values are
107
+ * not reloaded; call {@link Model.reload} to read the new numbers.
108
+ *
109
+ * @param fields - Attribute name(s) or map of amounts.
110
+ * @param options - `by` (default 1), `silent`, and query options.
111
+ * @returns This instance.
112
+ * @example
113
+ * ```ts
114
+ * await user.increment('loginCount');
115
+ * await user.increment({ loginCount: 2, score: 10 });
116
+ * ```
117
+ */
118
+ increment(fields: AttributeAmounts<TAttributes>, options?: Omit<IncrementOptions<TAttributes>, 'where'>): Promise<this>;
119
+ /**
120
+ * Decrements numeric attributes of this row in the database (`SET x = x - by`). The instance values are
121
+ * not reloaded; call {@link Model.reload} to read the new numbers.
122
+ *
123
+ * @param fields - Attribute name(s) or map of amounts.
124
+ * @param options - `by` (default 1), `silent`, and query options.
125
+ * @returns This instance.
126
+ * @example
127
+ * ```ts
128
+ * await user.decrement('credits', { by: 5 });
129
+ * ```
130
+ */
131
+ decrement(fields: AttributeAmounts<TAttributes>, options?: Omit<IncrementOptions<TAttributes>, 'where'>): Promise<this>;
132
+ }