imodel 0.20.0 → 0.20.2

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/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * imodel v0.20.0
2
+ * imodel v0.20.2
3
3
  * (c) 2019-2026 猛火Fierflame
4
4
  * @license MIT
5
5
  */
@@ -244,12 +244,6 @@ function setDefaultOptions(v) {
244
244
  return v;
245
245
  }
246
246
 
247
- const Destroy = Symbol();
248
- const PseudoDestroy = Symbol();
249
- const Save = Symbol();
250
- const Create = Symbol();
251
- const Build = Symbol();
252
-
253
247
  /** @import { TableDefine, FieldDefine } from '../types/table' */
254
248
  /** @import { DBIndex, DBTable } from '../types/connection' */
255
249
  /**
@@ -380,6 +374,12 @@ function table2db(tables) {
380
374
  return allTables;
381
375
  }
382
376
 
377
+ const Destroy = Symbol();
378
+ const PseudoDestroy = Symbol();
379
+ const Save = Symbol();
380
+ const Create = Symbol();
381
+ const Build = Symbol();
382
+
383
383
  function signal2promise(signal) {
384
384
  return new Promise((_, r) => {
385
385
  if (signal.aborted) {
@@ -428,7 +428,46 @@ function createInterface (connPromise, baseTransaction) {
428
428
  // TODO: 检测层数
429
429
  }
430
430
  }
431
+ function build(p, data, saved) {
432
+ if (typeof p[Build] === 'function') {
433
+ return p[Build](data, saved || false, {
434
+ isDevelopment,
435
+ values,
436
+ errors
437
+ });
438
+ }
439
+ if (typeof saved === 'boolean') {
440
+ return {
441
+ ...data
442
+ };
443
+ }
444
+ return {
445
+ ...data,
446
+ ...saved
447
+ };
448
+ }
431
449
  const ci = {
450
+ build,
451
+ async dbType() {
452
+ const conn = await connPromise;
453
+ return conn.dbType;
454
+ },
455
+ async dbVersion() {
456
+ const conn = await connPromise;
457
+ return conn.dbVersion(env);
458
+ },
459
+ async query(...values) {
460
+ const conn = await connPromise;
461
+ return conn.query(env, ...values);
462
+ },
463
+ async exec(...values) {
464
+ const conn = await connPromise;
465
+ return conn.exec(env, ...values);
466
+ },
467
+ async type(table) {
468
+ const conn = await connPromise;
469
+ return conn.type(env, table);
470
+ },
432
471
  async insert(table, data, keys, conflictTarget, conflictSet, conflictWhere) {
433
472
  const conn = await connPromise;
434
473
  return conn.insert(env, table.table, table.columns, data, keys, conflictTarget, conflictSet, conflictWhere);
@@ -999,41 +1038,43 @@ const withDeleted = Symbol();
999
1038
  /** @typedef {typeof withDeleted} withDeleted */
1000
1039
  /** @typedef {deleted | undeleted | withDeleted} FindRange */
1001
1040
 
1002
- /** @import { Options, Queryable } from '../types' */
1003
- /**
1004
- *
1005
- * @param {Partial<Queryable>} queryable
1006
- * @returns {Options}
1007
- */
1008
- function getOptions({
1041
+ function getPseudoWhere({
1009
1042
  fields,
1010
- pseudo,
1011
- options: modelOptions
1012
- }) {
1013
- const options = {
1014
- where: [],
1015
- ...modelOptions
1016
- };
1043
+ pseudo
1044
+ }, range) {
1017
1045
  if (!pseudo || !fields) {
1018
- return options;
1046
+ return null;
1019
1047
  }
1020
1048
  if (!(pseudo in fields)) {
1021
- return options;
1049
+ return null;
1022
1050
  }
1023
- if (options.range === undeleted) {
1024
- options.where = [...options.where, {
1051
+ if (range === undeleted) {
1052
+ return {
1025
1053
  field: pseudo,
1026
1054
  operator: '<>',
1027
1055
  value: 0
1028
- }];
1029
- } else if (options.range !== withDeleted) {
1030
- options.where = [...options.where, {
1056
+ };
1057
+ } else if (range !== withDeleted) {
1058
+ return {
1031
1059
  field: pseudo,
1032
1060
  operator: '=',
1033
1061
  value: 0
1034
- }];
1062
+ };
1063
+ }
1064
+ return null;
1065
+ }
1066
+ function getOptions(queryable) {
1067
+ const pseudoWhere = getPseudoWhere(queryable, queryable.options?.range);
1068
+ if (!pseudoWhere) {
1069
+ return {
1070
+ where: [],
1071
+ ...queryable.options
1072
+ };
1035
1073
  }
1036
- return options;
1074
+ return {
1075
+ ...queryable.options,
1076
+ where: [...(queryable.options?.where || []), pseudoWhere]
1077
+ };
1037
1078
  }
1038
1079
 
1039
1080
  function count (queryable) {
@@ -2486,7 +2527,7 @@ function sort2column(sort, fieldColumns) {
2486
2527
  return sort.map(([f, d]) => [fieldColumns[f], d]);
2487
2528
  }
2488
2529
 
2489
- /** @import Connection from './index.mjs' */
2530
+ /** @import Connection from './index.mts' */
2490
2531
  /** @import { FieldDefine, Fields, Skip, TableDefine, FieldType, SelectItem, LockType, ConnectionInterface } from '../types' */
2491
2532
 
2492
2533
  /**
@@ -2672,23 +2713,20 @@ async function search$1(conn, that, p, returnFields, skip) {
2672
2713
 
2673
2714
  /* eslint-disable max-len */
2674
2715
 
2716
+ /** @deprecated */
2675
2717
  function find (sql, skip) {
2676
2718
  return {
2677
2719
  connect: sql.connect,
2678
- async invoke(connect, connection, env) {
2720
+ async invoke(connect, connection) {
2679
2721
  const conn = await connect();
2680
2722
  const result = await search$1(conn, connection, sql, true, skip);
2681
- if (typeof sql[Build] !== 'function') {
2682
- return result;
2683
- }
2684
- const R = sql[Build].bind(sql);
2685
- return result.map(it => R(it, true, env));
2723
+ return result.map(it => conn.build(sql, it, true));
2686
2724
  }
2687
2725
  };
2688
2726
  }
2689
2727
 
2690
- /** @import Connection from './index.mjs' */
2691
- /** @import { Environment, TableDefine, Skip, SelectItem, ConnectionInterface, BaseEnvironment } from '../types' */
2728
+ /** @import Connection from './index.mts' */
2729
+ /** @import { TableDefine, Skip, SelectItem, ConnectionInterface } from '../types' */
2692
2730
 
2693
2731
  /**
2694
2732
  *
@@ -2696,11 +2734,10 @@ function find (sql, skip) {
2696
2734
  * @param {ConnectionInterface} conn
2697
2735
  * @param {Connection} that
2698
2736
  * @param {T} p
2699
- * @param {BaseEnvironment} env
2700
2737
  * @param {Skip} [skip]
2701
2738
  * @returns {Promise<any>}
2702
2739
  */
2703
- async function first$1(conn, that, p, env, skip) {
2740
+ async function first$1(conn, that, p, skip) {
2704
2741
  const {
2705
2742
  table,
2706
2743
  fields
@@ -2735,18 +2772,15 @@ async function first$1(conn, that, p, env, skip) {
2735
2772
  if (!item) {
2736
2773
  return null;
2737
2774
  }
2738
- if (typeof p[Build] !== 'function') {
2739
- return item;
2740
- }
2741
- return p[Build](item, true, env);
2775
+ return conn.build(p, item);
2742
2776
  }
2743
2777
 
2744
2778
  function first (sql, skip) {
2745
2779
  return {
2746
2780
  connect: sql.connect,
2747
- async invoke(connect, connection, env) {
2781
+ async invoke(connect, connection) {
2748
2782
  const conn = await connect();
2749
- return first$1(conn, connection, sql, env, skip);
2783
+ return first$1(conn, connection, sql, skip);
2750
2784
  }
2751
2785
  };
2752
2786
  }
@@ -3343,6 +3377,7 @@ function save (model, data, newData, skip) {
3343
3377
  };
3344
3378
  }
3345
3379
 
3380
+ /** @deprecated */
3346
3381
  function search (sql, fields, skip) {
3347
3382
  return {
3348
3383
  connect: sql.connect,
@@ -3396,6 +3431,7 @@ function toSelect(queryable, lockable) {
3396
3431
  };
3397
3432
  }
3398
3433
 
3434
+ /** @deprecated */
3399
3435
  function select (queryable) {
3400
3436
  return {
3401
3437
  connect: queryable.connect,
@@ -3555,6 +3591,91 @@ function upsert ({
3555
3591
  };
3556
3592
  }
3557
3593
 
3594
+ const falseValues = new Set(['', '0', 'n', 'f', 'no', 'off', 'false', '否', '不', '假', '不是', '不行', '不可以']);
3595
+
3596
+ /**
3597
+ *
3598
+ * @param {any} v
3599
+ * @returns
3600
+ */
3601
+ function toBool(v) {
3602
+ if (typeof v !== 'string') {
3603
+ return Boolean(v);
3604
+ }
3605
+ return !falseValues.has(v.toLowerCase());
3606
+ }
3607
+
3608
+ /** @import Connection from './index.mts' */
3609
+ /** @import { TableDefine, Skip, SelectItem, ConnectionInterface } from '../types' */
3610
+
3611
+ function get (model, primary, options) {
3612
+ return {
3613
+ connect: model.connect,
3614
+ async invoke(connect, connection) {
3615
+ const primaryFields = Object.entries(model.fields).filter(([, v]) => v.primary).sort(([, a], [, b]) => Number(a.primary) - Number(b.primary));
3616
+ if (!primaryFields.length) {
3617
+ throw new Error('no primary key');
3618
+ }
3619
+ const wheres = new Where();
3620
+ if (primaryFields.length === 1) {
3621
+ const [[field]] = primaryFields;
3622
+ wheres.and(field, primary);
3623
+ } else if (typeof primary === 'object') {
3624
+ for (const [p] of primaryFields) {
3625
+ wheres.and(p, primary[p]);
3626
+ }
3627
+ } else {
3628
+ const values = `${primary}`.split('$');
3629
+ if (values.length !== primaryFields.length) ;
3630
+ for (const [i, [p, {
3631
+ type
3632
+ }]] of primaryFields.entries()) {
3633
+ const value = values[i] ?? null;
3634
+ const val = type !== 'bool' || value === null ? value : toBool(value);
3635
+ wheres.and(p, val);
3636
+ }
3637
+ }
3638
+ const whereValues = Where.parseParams([wheres]) || [];
3639
+ const pseudoWhere = getPseudoWhere(model, options?.range);
3640
+ if (pseudoWhere) {
3641
+ whereValues.push(pseudoWhere);
3642
+ }
3643
+ const {
3644
+ table,
3645
+ fields
3646
+ } = model;
3647
+ const lock = options?.lock;
3648
+ const [columns, fieldColumns, tableFields] = toColumns(fields);
3649
+ const where = where2column(whereValues, fieldColumns);
3650
+ where.push(...getFixedValueWhere(columns));
3651
+ const whereHook = !options?.skipWhere && (await model.hooks?.where?.(connection, model));
3652
+ if (whereHook) {
3653
+ where.push(...where2column(Where.parse(whereHook), fieldColumns));
3654
+ }
3655
+ /** @type {SelectItem} */
3656
+ const selects = {
3657
+ table: typeof table === 'string' ? table : '',
3658
+ columns,
3659
+ where,
3660
+ limit: 1,
3661
+ sort: [],
3662
+ select: select2column(columns, fieldColumns),
3663
+ group: [],
3664
+ having: [],
3665
+ lock: options?.lock
3666
+ };
3667
+ const conn = await connect();
3668
+ const list = await conn.select(selects);
3669
+ const baseFieldSet = new Set(Object.keys(fieldColumns || columns));
3670
+ const [item] = await findSub(conn, list, tableFields, baseFieldSet, lock);
3671
+ if (!item) {
3672
+ return null;
3673
+ }
3674
+ return conn.build(model, item);
3675
+ }
3676
+ };
3677
+ }
3678
+
3558
3679
  var index$1 = /*#__PURE__*/Object.freeze({
3559
3680
  __proto__: null,
3560
3681
  completelyDestroy: completelyDestroy,
@@ -3566,6 +3687,7 @@ var index$1 = /*#__PURE__*/Object.freeze({
3566
3687
  destroyMany: destroyMany,
3567
3688
  find: find,
3568
3689
  first: first,
3690
+ get: get,
3569
3691
  insert: insert,
3570
3692
  pseudoDestroy: pseudoDestroy,
3571
3693
  save: save,
@@ -3578,50 +3700,22 @@ var index$1 = /*#__PURE__*/Object.freeze({
3578
3700
  upsert: upsert
3579
3701
  });
3580
3702
 
3581
- /** @import { Wheres } from '../Where.mjs' */
3582
- /** @import { SetValue } from '../set.mjs' */
3583
- /** @import { Environment, TableValue } from '../types' */
3584
- /** @import { Fields, FieldValue, IndexOptions, MainFieldType, TableDefine } from '../types/table' */
3585
- /** @import { Queryable } from '../types/options' */
3586
- /** @import { Column, ColumnOptions } from '../types/column' */
3587
- /** @import { Action, ConnectionInterface, DBTable, IConnection, Savepoint, Skip, TableType, TransactionHandler } from '../types/connection' */
3588
-
3703
+ /* eslint-disable max-lines */
3589
3704
 
3590
- /**
3591
- * @template {{}} [E={}]
3592
- */
3593
3705
  class Connection {
3594
- /** @type {Environment<E>} */
3595
3706
  #env;
3596
- /** @type {() => Promise<IConnection<E>>} */
3597
3707
  #getConnection;
3598
- /** @type {E?} */
3599
3708
  #baseTransaction;
3600
- /**
3601
- *
3602
- * @param {PromiseLike<IConnection<E>> | IConnection<E>} connection
3603
- * @param {E?} [transaction]
3604
- */
3605
3709
  constructor(connection, transaction = null) {
3606
3710
  this.#baseTransaction = transaction;
3607
3711
  const getConnection = async () => connection;
3608
3712
  this.#getConnection = getConnection;
3609
3713
  [this.#interface, this.#env] = createInterface(connection, transaction);
3610
3714
  }
3611
- /** @type {ConnectionInterface} */
3612
3715
  #interface;
3613
- /**
3614
- *
3615
- * @returns {Connection<E>}
3616
- */
3617
3716
  clone() {
3618
3717
  return new Connection(this.#getConnection(), this.#baseTransaction);
3619
3718
  }
3620
- /**
3621
- * @template T
3622
- * @param {Action<T>} action
3623
- * @returns {Promise<T>}
3624
- */
3625
3719
  async call(action) {
3626
3720
  const env = {
3627
3721
  isDevelopment,
@@ -3638,693 +3732,245 @@ class Connection {
3638
3732
  let conn = null;
3639
3733
  return action.invoke(() => conn ||= connect(), this, env);
3640
3734
  }
3641
-
3642
- /** @return {Promise<string>} */
3643
3735
  async dbType() {
3644
- const conn = await this.#getConnection();
3645
- return conn.dbType;
3736
+ return this.#interface.dbType();
3646
3737
  }
3647
- /** @return {Promise<string>} */
3648
3738
  async dbVersion() {
3649
- const conn = await this.#getConnection();
3650
- return conn.dbVersion(this.#env);
3739
+ return this.#interface.dbVersion();
3651
3740
  }
3652
- /**
3653
- *
3654
- * @param {...any} values
3655
- * @returns {Promise<any[]>}
3656
- */
3657
3741
  async query(...values) {
3658
- const conn = await this.#getConnection();
3659
- return conn.query(this.#env, ...values);
3742
+ return this.#interface.query(...values);
3660
3743
  }
3661
- /**
3662
- *
3663
- * @param {...any} values
3664
- * @returns {Promise<number>}
3665
- */
3666
3744
  async exec(...values) {
3667
- const conn = await this.#getConnection();
3668
- return conn.exec(this.#env, ...values);
3745
+ return this.#interface.exec(...values);
3669
3746
  }
3670
- /**
3671
- *
3672
- * @param {string} table
3673
- * @returns {Promise<TableType?>}
3674
- */
3675
3747
  async type(table) {
3676
- const conn = await this.#getConnection();
3677
- return conn.type(this.#env, table);
3748
+ return this.#interface.type(table);
3678
3749
  }
3679
- /**
3680
- * @template T
3681
- * @overload
3682
- * @param {Build<T>} build
3683
- * @param {object} data
3684
- * @param {object | boolean} [saved]
3685
- * @returns {T}
3686
- */
3687
- /**
3688
- * @template {Fields} T
3689
- * @overload
3690
- * @param {TableDefine<T>} table
3691
- * @param {object} data
3692
- * @param {object | boolean} [saved]
3693
- * @returns {FieldValue<T>}
3694
- */
3695
- /**
3696
- * @param {Build | TableDefine} p
3697
- * @param {object} data
3698
- * @param {object | boolean} [saved]
3699
- * @returns {any}
3700
- */
3701
3750
  build(p, data, saved) {
3702
- if (typeof p[Build] === 'function') {
3703
- return p[Build](data, saved || false, this.#env);
3704
- }
3705
- if (typeof saved === 'boolean') {
3706
- return {
3707
- ...data
3708
- };
3709
- }
3710
- return {
3711
- ...data,
3712
- ...saved
3713
- };
3751
+ return this.#interface.build(p, data, saved);
3714
3752
  }
3715
- /**
3716
- * @deprecated
3717
- * @template {TableDefine} T
3718
- * @overload
3719
- * @param {T} model
3720
- * @param {object[]} list
3721
- * @returns {Promise<TableValue<T>[]>}
3722
- */
3723
- /**
3724
- * @deprecated
3725
- * @template {TableDefine} T
3726
- * @overload
3727
- * @param {T} model
3728
- * @param {object} value
3729
- * @returns {Promise<T extends Build<infer R> ? R : TableValue<T>>}
3730
- */
3731
- /**
3732
- * @deprecated
3733
- * @template {TableDefine} T
3734
- * @overload
3735
- * @param {T} model
3736
- * @param {object | object[]} value
3737
- * @returns {Promise<TableValue<T>[] | (T extends Build<infer R> ? R : TableValue<T>)>}
3738
- */
3739
- /**
3740
- * @deprecated
3741
- * @template {TableDefine} T
3742
- * @param {T} model
3743
- * @param {object | object[]} p
3744
- * @param {Skip} [skip]
3745
- * @returns {Promise<TableValue<T>[] | (T extends Build<infer R> ? R : TableValue<T>)>}
3746
- */
3753
+ /** @deprecated */
3754
+
3755
+ /** @deprecated */
3756
+
3757
+ /** @deprecated */
3758
+
3759
+ /** @deprecated */
3747
3760
  async create(model, p, skip) {
3748
3761
  return this.call(create(model, p, skip));
3749
3762
  }
3750
- /**
3751
- *
3752
- * @deprecated
3753
- * @template {TableDefine} T
3754
- * @param {T} sql
3755
- * @param {string[]} fields
3756
- * @param {Skip} [skip]
3757
- * @returns {Promise<T extends TableDefine<infer F> ? FieldValue<F>[] : never>}
3758
- */
3763
+ /** @deprecated */
3759
3764
  async search(sql, fields, skip) {
3760
3765
  return this.call(search(sql, fields, skip));
3761
3766
  }
3762
- /**
3763
- * @deprecated
3764
- * @template {TableDefine} T
3765
- * @param {T} sql
3766
- * @param {Skip} [skip]
3767
- * @returns {Promise<T extends Build<infer R > ? R[] : T extends TableDefine<infer F> ? FieldValue<F>[] : never>}
3768
- */
3767
+ /** @deprecated */
3769
3768
  async find(sql, skip) {
3770
3769
  return this.call(find(sql, skip));
3771
3770
  }
3772
- /**
3773
- *
3774
- * @deprecated
3775
- * @template {TableDefine} T
3776
- * @param {T} sql
3777
- * @param {Skip} [skip]
3778
- * @returns {Promise<T extends Build<infer R > ? R : T extends TableDefine<infer F> ? FieldValue<F> : never>}
3779
- */
3771
+ /** @deprecated */
3780
3772
  async first(sql, skip) {
3781
3773
  return this.call(first(sql, skip));
3782
3774
  }
3783
- /**
3784
- * @deprecated
3785
- * @template T
3786
- * @param {TableDefine} model
3787
- * @param {T} data
3788
- * @param {Record<string, any>?} [newData]
3789
- * @param {Skip} [skip]
3790
- * @returns {Promise<(T extends Save ? T : object)?>}
3791
- */
3775
+ /** @deprecated */
3792
3776
  async save(model, data, newData, skip) {
3793
3777
  return this.call(save(model, data, newData, skip));
3794
3778
  }
3795
- /**
3796
- *
3797
- * @deprecated
3798
- * @template T
3799
- * @param {TableDefine} tableDef
3800
- * @param {T} data
3801
- * @returns {Promise<(T extends Destroy ? T : object)?>}
3802
- */
3779
+ /** @deprecated */
3803
3780
  async completelyDestroy(tableDef, data) {
3804
3781
  return this.call(completelyDestroy(tableDef, data));
3805
3782
  }
3806
- /**
3807
- *
3808
- * @deprecated
3809
- * @template {object} T
3810
- * @param {TableDefine} tableDef
3811
- * @param {T} data
3812
- * @param {Record<string, SetValue>} value
3813
- * @returns {Promise<(T extends PseudoDestroy ? T : object)?>}
3814
- */
3783
+ /** @deprecated */
3815
3784
  async pseudoDestroy(tableDef, data, value) {
3816
3785
  return this.call(pseudoDestroy(tableDef, data, value));
3817
3786
  }
3818
- /**
3819
- * @deprecated
3820
- * @template {Destroy & PseudoDestroy} T
3821
- * @overload
3822
- * @param {TableDefine} table
3823
- * @param {T} data
3824
- * @param {Record<string, any> | boolean} [update]
3825
- * @returns {Promise<T?>}
3826
- */
3827
- /**
3828
- * @deprecated
3829
- * @template {Destroy & PseudoDestroy} T
3830
- * @overload
3831
- * @param {TableDefine} table
3832
- * @param {T} data
3833
- * @param {Record<string, any> | boolean} [update]
3834
- * @returns {Promise<T | object | null>}
3835
- */
3836
- /**
3837
- * @deprecated
3838
- * @overload
3839
- * @param {TableDefine} table
3840
- * @param {any} data
3841
- * @param {Record<string, any> | boolean} [update]
3842
- * @returns {Promise<object?>}
3843
- */
3844
- /**
3845
- * @deprecated
3846
- * @param {TableDefine} tableDef
3847
- * @param {any} data
3848
- * @param {Record<string, any> | boolean} [update]
3849
- * @returns {Promise<object?>}
3850
- */
3787
+ /** @deprecated */
3788
+
3789
+ /** @deprecated */
3790
+
3791
+ /** @deprecated */
3792
+
3793
+ /** @deprecated */
3851
3794
  async destroy(tableDef, data, update) {
3852
3795
  return this.call(destroy(tableDef, data, update));
3853
3796
  }
3854
- /**
3855
- * @deprecated
3856
- * @param {Queryable} queryable
3857
- * @param {Record<string, SetValue> | boolean} [update]
3858
- * @returns {Promise<number>}
3859
- */
3797
+ /** @deprecated */
3860
3798
  async destroyMany(queryable, update) {
3861
3799
  return this.call(destroyMany(queryable, update));
3862
3800
  }
3863
- /**
3864
- * @deprecated
3865
- * @template {object} T
3866
- * @overload
3867
- * @param {TableDefine} tableDefine
3868
- * @param {T} data
3869
- * @param {boolean} [ignoreConflict]
3870
- * @returns {Promise<T>}
3871
- */
3872
- /**
3873
- * @deprecated
3874
- * @template {object} T
3875
- * @overload
3876
- * @param {TableDefine} tableDefine
3877
- * @param {T[]} data
3878
- * @param {boolean} [ignoreConflict]
3879
- * @returns {Promise<T[]>}
3880
- */
3881
- /**
3882
- * @deprecated
3883
- * @template {object} T
3884
- * @overload
3885
- * @param {TableDefine} tableDefine
3886
- * @param {T} data
3887
- * @param {string[]} [keys]
3888
- * @param {boolean} [ignoreConflict]
3889
- * @returns {Promise<T>}
3890
- */
3891
- /**
3892
- * @deprecated
3893
- * @template {object} T
3894
- * @overload
3895
- * @param {TableDefine} tableDefine
3896
- * @param {T[]} data
3897
- * @param {string[]} [keys]
3898
- * @param {boolean} [ignoreConflict]
3899
- * @returns {Promise<T[]>}
3900
- */
3901
- /**
3902
- * @deprecated
3903
- * @template {object} T
3904
- * @overload
3905
- * @param {TableDefine} tableDefine
3906
- * @param {T} data
3907
- * @param {string[] | boolean} [keys]
3908
- * @param {boolean} [ignoreConflict]
3909
- * @returns {Promise<T>}
3910
- */
3911
- /**
3912
- * @deprecated
3913
- * @template {object} T
3914
- * @overload
3915
- * @param {TableDefine} tableDefine
3916
- * @param {T[]} data
3917
- * @param {string[] | boolean} [keys]
3918
- * @param {boolean} [ignoreConflict]
3919
- * @returns {Promise<T[]>}
3920
- */
3921
- /**
3922
- * @deprecated
3923
- * @template {object} T
3924
- * @overload
3925
- * @param {TableDefine} tableDefine
3926
- * @param {T | T[]} data
3927
- * @param {string[] | boolean} [keys]
3928
- * @param {boolean} [ignoreConflict]
3929
- * @returns {Promise<T | T[]>}
3930
- */
3931
- /**
3932
- * @deprecated
3933
- * @template {object} T
3934
- * @param {TableDefine} table
3935
- * @param {T | T[]} data
3936
- * @param {string[] | boolean} [keys]
3937
- * @param {boolean} [ignoreConflict]
3938
- * @returns {Promise<T | T[]>}
3939
- */
3801
+ /** @deprecated */
3802
+
3803
+ /** @deprecated */
3804
+
3805
+ /** @deprecated */
3806
+
3807
+ /** @deprecated */
3808
+
3809
+ /** @deprecated */
3810
+
3811
+ /** @deprecated */
3812
+
3813
+ /** @deprecated */
3814
+
3815
+ /** @deprecated */
3940
3816
  async insert(table, data, keys, ignoreConflict) {
3941
3817
  // @ts-ignore
3942
3818
  return this.call(insert(table, data, keys, ignoreConflict));
3943
3819
  }
3944
- /**
3945
- * @deprecated
3946
- * @template {object} T
3947
- * @overload
3948
- * @param {TableDefine} tableDefine
3949
- * @param {T} data
3950
- * @param {Record<string, SetValue>} [conflictSet]
3951
- * @returns {Promise<T>}
3952
- */
3953
- /**
3954
- * @deprecated
3955
- * @template {object} T
3956
- * @overload
3957
- * @param {TableDefine} tableDefine
3958
- * @param {T[]} data
3959
- * @param {Record<string, SetValue>} [conflictSet]
3960
- * @returns {Promise<T[]>}
3961
- */
3962
- /**
3963
- * @deprecated
3964
- * @template {object} T
3965
- * @overload
3966
- * @param {TableDefine} tableDefine
3967
- * @param {T} data
3968
- * @param {null | string[]} [keys]
3969
- * @param {Record<string, SetValue>} [conflictSet]
3970
- * @returns {Promise<T>}
3971
- */
3972
- /**
3973
- * @deprecated
3974
- * @template {object} T
3975
- * @overload
3976
- * @param {TableDefine} tableDefine
3977
- * @param {T[]} data
3978
- * @param {null | string[]} [keys]
3979
- * @param {Record<string, SetValue>} [conflictSet]
3980
- * @returns {Promise<T[]>}
3981
- */
3982
- /**
3983
- * @deprecated
3984
- * @template {object} T
3985
- * @overload
3986
- * @param {TableDefine} tableDefine
3987
- * @param {T} data
3988
- * @param {null | string[]} [keys]
3989
- * @param {string[] | boolean} [conflictKeys]
3990
- * @param {Record<string, SetValue>} [conflictSet]
3991
- * @returns {Promise<T>}
3992
- */
3993
- /**
3994
- * @deprecated
3995
- * @template {object} T
3996
- * @overload
3997
- * @param {TableDefine} tableDefine
3998
- * @param {T[]} data
3999
- * @param {null | string[]} [keys]
4000
- * @param {string[] | boolean} [conflictKeys]
4001
- * @param {Record<string, SetValue>} [conflictSet]
4002
- * @returns {Promise<T[]>}
4003
- */
4004
- /**
4005
- * @deprecated
4006
- * @template {object} T
4007
- * @overload
4008
- * @param {TableDefine} tableDefine
4009
- * @param {T} data
4010
- * @param {null | string[] | boolean | Record<string, SetValue>} [keys]
4011
- * @param {string[] | boolean | Record<string, SetValue>} [conflictKeys]
4012
- * @param {Record<string, SetValue>} [conflictSet]
4013
- * @returns {Promise<T>}
4014
- */
4015
- /**
4016
- * @deprecated
4017
- * @template {object} T
4018
- * @overload
4019
- * @param {TableDefine} tableDefine
4020
- * @param {T[]} data
4021
- * @param {null | string[] | boolean | Record<string, SetValue>} [keys]
4022
- * @param {string[] | boolean | Record<string, SetValue>} [conflictKeys]
4023
- * @param {Record<string, SetValue>} [conflictSet]
4024
- * @returns {Promise<T[]>}
4025
- */
4026
- /**
4027
- * @deprecated
4028
- * @template {object} T
4029
- * @overload
4030
- * @param {TableDefine} tableDefine
4031
- * @param {T | T[]} data
4032
- * @param {null | string[] | boolean | Record<string, SetValue>} [keys]
4033
- * @param {string[] | boolean | Record<string, SetValue>} [conflictKeys]
4034
- * @param {Record<string, SetValue>} [conflictSet]
4035
- * @returns {Promise<T | T[]>}
4036
- */
4037
- /**
4038
- * @deprecated
4039
- * @template {object} T
4040
- * @param {TableDefine} tableDefine
4041
- * @param {T | T[]} data
4042
- * @param {null | string[] | boolean | Record<string, SetValue>} [keys]
4043
- * @param {string[] | boolean | Record<string, SetValue>} [conflictKeys]
4044
- * @param {Record<string, SetValue>} [conflictSet]
4045
- * @returns {Promise<T | T[]>}
4046
- */
3820
+ /** @deprecated */
3821
+
3822
+ /** @deprecated */
3823
+
3824
+ /** @deprecated */
3825
+
3826
+ /** @deprecated */
3827
+
3828
+ /** @deprecated */
3829
+
3830
+ /** @deprecated */
3831
+
3832
+ /** @deprecated */
3833
+
3834
+ /** @deprecated */
3835
+
3836
+ /** @deprecated */
3837
+
3838
+ /** @deprecated */
4047
3839
  async upsert(tableDefine, data, keys, conflictKeys, conflictSet) {
4048
3840
  // @ts-ignore
4049
3841
  return this.call(
4050
3842
  // @ts-ignore
4051
3843
  upsert(tableDefine, data, keys, conflictKeys, conflictSet));
4052
3844
  }
4053
- /**
4054
- * @deprecated
4055
- * @param {TableDefine} table
4056
- * @param {Record<string, any>} update
4057
- * @param {Wheres?} [where]
4058
- * @param {boolean | Skip} [skip]
4059
- * @returns {Promise<number>}
4060
- */
3845
+ /** @deprecated */
4061
3846
  async update(table, update$1, where, skip) {
4062
3847
  return this.call(update(table, update$1, where, skip));
4063
3848
  }
4064
- /**
4065
- * @deprecated
4066
- * @template {Fields<MainFieldType>} T
4067
- * @param {TableDefine<T>} table
4068
- * @param {Record<string, any>} update
4069
- * @param {string[]?} [returning]
4070
- * @param {Wheres?} [where]
4071
- * @param {boolean | Skip} [skip]
4072
- * @returns {Promise<any[]>}
4073
- */
3849
+ /** @deprecated */
4074
3850
  async updateReturn(table, update, returning, where, skip) {
4075
3851
  return this.call(updateReturn(table, update, returning, where, skip));
4076
3852
  }
4077
- /**
4078
- * @deprecated
4079
- * @param {TableDefine} table
4080
- * @param {string[]} pKeys
4081
- * @param {string[]} setKeys
4082
- * @param {Record<string, any>[]} list
4083
- * @param {boolean | Skip} [skip]
4084
- * @returns {Promise<number>}
4085
- */
3853
+ /** @deprecated */
4086
3854
  async updateMany(table, pKeys, setKeys, list, skip) {
4087
3855
  return this.call(updateList(table, pKeys, setKeys, list, skip));
4088
3856
  }
4089
- /**
4090
- * @deprecated
4091
- * @template {Fields<MainFieldType>} T
4092
- * @param {TableDefine<T>} table
4093
- * @param {string[]} pKeys
4094
- * @param {string[]} setKeys
4095
- * @param {Record<string, any>[]} list
4096
- * @param {string[]?} [returning]
4097
- * @param {boolean | Skip} [skip]
4098
- * @returns {Promise<any[]>}
4099
- */
3857
+ /** @deprecated */
4100
3858
  async updateManyReturn(table, pKeys, setKeys, list, returning, skip) {
4101
3859
  return this.call(updateListReturn(table, pKeys, setKeys, list, returning, skip));
4102
3860
  }
4103
- /**
4104
- * @deprecated
4105
- * @param {TableDefine} table
4106
- * @param {Wheres?} [where]
4107
- * @returns {Promise<number>}
4108
- */
3861
+ /** @deprecated */
4109
3862
  async delete(table, where) {
4110
3863
  return this.call(_delete(table, where));
4111
3864
  }
4112
-
4113
- /**
4114
- * @deprecated
4115
- * @template {Fields<MainFieldType>} T
4116
- * @param {TableDefine<T>} table
4117
- * @param {string[]?} [returning]
4118
- * @param {Wheres?} [where]
4119
- * @returns {Promise<any[]>}
4120
- */
3865
+ /** @deprecated */
4121
3866
  async deleteReturn(table, returning, where) {
4122
3867
  return this.call(deleteReturn(table, returning, where));
4123
3868
  }
4124
- /**
4125
- *
4126
- * @deprecated
4127
- * @param {Queryable} queryable
4128
- * @returns {Promise<number>}
4129
- */
3869
+ /** @deprecated */
4130
3870
  async count(queryable) {
4131
3871
  return this.call(count(queryable));
4132
3872
  }
4133
- /**
4134
- * @deprecated
4135
- * @param {Queryable} queryable
4136
- * @returns {Promise<any[]>}
4137
- */
3873
+ /** @deprecated */
4138
3874
  async select(queryable) {
4139
3875
  return this.call(select(queryable));
4140
3876
  }
4141
- /**
4142
- * @param {string} table
4143
- * @param {string} column
4144
- * @param {string} type
4145
- * @param {ColumnOptions<any>} options
4146
- * @returns {Promise<number>}
4147
- */
4148
3877
  async addColumn(table, column, type, options) {
4149
3878
  const conn = await this.#getConnection();
4150
3879
  return conn.addColumn(this.#env, table, column, type, setDefaultOptions(options));
4151
3880
  }
4152
- /**
4153
- * @param {string} table
4154
- * @param {string} column
4155
- * @param {string} type
4156
- * @param {ColumnOptions<any>} options
4157
- * @returns {Promise<number>}
4158
- */
4159
3881
  async changeColumn(table, column, type, options) {
4160
3882
  const conn = await this.#getConnection();
4161
3883
  return conn.changeColumn(this.#env, table, column, type, setDefaultOptions(options));
4162
3884
  }
4163
- /**
4164
- * @param {string} table
4165
- * @param {string} column
4166
- * @param {boolean} nullable
4167
- * @returns {Promise<number>}
4168
- */
4169
3885
  async changeColumnNull(table, column, nullable) {
4170
3886
  const conn = await this.#getConnection();
4171
3887
  return conn.changeColumnNull(this.#env, table, column, nullable);
4172
3888
  }
4173
- /**
4174
- * @param {string} table
4175
- * @param {string} column
4176
- * @returns {Promise<number>}
4177
- */
4178
3889
  async dropColumn(table, column) {
4179
3890
  const conn = await this.#getConnection();
4180
3891
  return conn.dropColumn(this.#env, table, column);
4181
3892
  }
4182
- /**
4183
- * @param {string} table
4184
- * @param {string} column
4185
- * @param {string} newName
4186
- * @returns {Promise<number>}
4187
- */
4188
3893
  async renameColumn(table, column, newName) {
4189
3894
  const conn = await this.#getConnection();
4190
3895
  return conn.renameColumn(this.#env, table, column, newName);
4191
3896
  }
4192
- /**
4193
- * @param {string} table
4194
- * @param {string} name
4195
- * @param {string[]} fields
4196
- * @param {IndexOptions} [options]
4197
- * @returns {Promise<number>}
4198
- */
4199
3897
  async addIndex(table, name, fields, options = {}) {
4200
3898
  const conn = await this.#getConnection();
4201
3899
  return conn.addIndex(this.#env, table, name, fields, options);
4202
3900
  }
4203
- /**
4204
- * @param {string} table
4205
- * @param {string} name
4206
- * @returns {Promise<number>}
4207
- */
4208
3901
  async dropIndex(table, name) {
4209
3902
  const conn = await this.#getConnection();
4210
3903
  return conn.dropIndex(this.#env, table, name);
4211
3904
  }
4212
- /**
4213
- * @param {string} table
4214
- * @param {Column<any>[]} fields
4215
- * @returns {Promise<number>}
4216
- */
4217
3905
  async createTable(table, fields) {
4218
3906
  const conn = await this.#getConnection();
4219
3907
  return conn.createTable(this.#env, table, fields.map(setDefaultOptions));
4220
3908
  }
4221
- /**
4222
- * @param {string} table
4223
- * @returns {Promise<number>}
4224
- */
4225
3909
  async dropTable(table) {
4226
3910
  const conn = await this.#getConnection();
4227
3911
  return conn.dropTable(this.#env, table);
4228
3912
  }
4229
- /**
4230
- * @param {string} table
4231
- * @param {string} newName
4232
- * @returns {Promise<number>}
4233
- */
4234
3913
  async renameTable(table, newName) {
4235
3914
  const conn = await this.#getConnection();
4236
3915
  return conn.renameTable(this.#env, table, newName);
4237
3916
  }
4238
- /**
4239
- * @template T
4240
- * @param {(signal: AbortSignal) => PromiseLike<T> | T} fn
4241
- * @returns {Promise<T>}
4242
- */
4243
- async #transaction(fn) {
4244
- return this.#interface.transaction(fn);
4245
- }
4246
- abort() {
4247
- return this.#interface.abort();
4248
- }
4249
- /**
4250
- * @returns {Promise<Savepoint>}
4251
- */
4252
- async savepoint() {
4253
- return this.#interface.savepoint();
4254
- }
4255
- [Symbol.dispose]() {
4256
- this.#interface.abort();
4257
- }
4258
- /**
4259
- * @param {string} table
4260
- * @returns {Promise<DBTable?>}
4261
- */
4262
3917
  async loadTable(table) {
4263
3918
  const conn = await this.#getConnection();
4264
3919
  return conn.loadTables(this.#env, [table]).then(v => v[0] || null);
4265
3920
  }
4266
- /**
4267
- * @param {string[]} tables
4268
- * @returns {Promise<DBTable[]>}
4269
- */
4270
3921
  async loadTables(tables) {
4271
3922
  const conn = await this.#getConnection();
4272
3923
  return conn.loadTables(this.#env, tables);
4273
3924
  }
4274
- /**
4275
- * @param {TableDefine | DBTable} table
4276
- * @returns {Promise<void>}
4277
- */
4278
3925
  async syncTable(table) {
4279
3926
  const conn = await this.#getConnection();
4280
3927
  return conn.syncTables(this.#env, table2db([table]));
4281
3928
  }
4282
- /**
4283
- * @param {(TableDefine | DBTable)[]} tables
4284
- * @returns {Promise<void>}
4285
- */
4286
3929
  async syncTables(tables) {
4287
3930
  const conn = await this.#getConnection();
4288
3931
  return conn.syncTables(this.#env, table2db(tables));
4289
3932
  }
3933
+ async #transaction(fn) {
3934
+ return this.#interface.transaction(fn);
3935
+ }
3936
+ abort() {
3937
+ return this.#interface.abort();
3938
+ }
3939
+ async savepoint() {
3940
+ return this.#interface.savepoint();
3941
+ }
3942
+ [Symbol.dispose]() {
3943
+ this.#interface.abort();
3944
+ }
4290
3945
  /**
4291
3946
  * @template T
4292
3947
  * @overload
4293
- * @param {(t: Connection) => PromiseLike<T> | T} fn
3948
+ * @param {Action<T> |((t: Connection, signal: AbortSignal) => PromiseLike<T> | T)} fn
4294
3949
  * @returns {Promise<T>}
4295
3950
  */
4296
- /**
4297
- * @overload
4298
- * @returns {TransactionHandler}
4299
- */
4300
- /**
4301
- *
4302
- * @template T
4303
- * @param {(t: Connection, signal: AbortSignal) => PromiseLike<T> | T} [fn]
4304
- * @returns {Promise<T> | TransactionHandler}
4305
- */
4306
- /**
4307
- *
4308
- * @template T
4309
- * @param {(t: Connection, signal: AbortSignal) => PromiseLike<T> | T} [fn]
4310
- * @returns {Promise<T> | TransactionHandler}
4311
- */
3951
+
4312
3952
  transaction(fn) {
3953
+ if (Array.isArray(fn)) {
3954
+ return this.#transaction(signal => Promise.all(fn.map(v => {
3955
+ if (typeof v === 'function') {
3956
+ return v(this, signal);
3957
+ }
3958
+ return this.call(v);
3959
+ })));
3960
+ }
4313
3961
  if (typeof fn === 'function') {
4314
3962
  return this.#transaction(signal => fn(this, signal));
4315
3963
  }
4316
- /** @type {(p: AbortSignal) => void} */
3964
+ if (fn && typeof fn === 'object') {
3965
+ return this.#transaction(() => this.call(fn));
3966
+ }
4317
3967
  let throwAborted = () => {};
4318
- /** @type {Promise<void>} */
4319
3968
  const abortedPromise = new Promise((_, r) => {
4320
3969
  throwAborted = r;
4321
3970
  });
4322
3971
  abortedPromise.catch(() => {});
4323
- /** @type {() => void} */
4324
3972
  let commit = () => {};
4325
- /** @type {(e?: any) => void} */
4326
3973
  let rollback = () => {};
4327
- /** @type {Promise<void>} */
4328
3974
  const donePromise = new Promise((r1, r2) => {
4329
3975
  commit = r1;
4330
3976
  rollback = r2;
@@ -4337,7 +3983,7 @@ class Connection {
4337
3983
  }
4338
3984
  return donePromise;
4339
3985
  }).then(() => {}, () => {});
4340
- const handler = /** @type {TransactionHandler} */[abortedPromise, () => {
3986
+ const handler = [abortedPromise, () => {
4341
3987
  commit();
4342
3988
  return dbiPromise;
4343
3989
  }, e => {
@@ -5638,21 +5284,7 @@ function coefficient(...value) {
5638
5284
  };
5639
5285
  }
5640
5286
 
5641
- const falseValues = new Set(['', '0', 'n', 'f', 'no', 'off', 'false', '否', '不', '假', '不是', '不行', '不可以']);
5642
-
5643
- /**
5644
- *
5645
- * @param {any} v
5646
- * @returns
5647
- */
5648
- function toBool(v) {
5649
- if (typeof v !== 'string') {
5650
- return Boolean(v);
5651
- }
5652
- return !falseValues.has(v.toLowerCase());
5653
- }
5654
-
5655
- /** @import { FieldDefine, Fields, LockType, Options, Queryable, Select } from './types' */
5287
+ /** @import { Action, FieldDefine, Fields, FieldValue, LockType, Options, Queryable, Select, Skip, TableConnect } from './types' */
5656
5288
  /** @import { WhereValue, Wheres } from './Where.mjs' */
5657
5289
  /**
5658
5290
  *
@@ -5710,14 +5342,16 @@ function selectFn(fn, select, newSelect) {
5710
5342
  * @template {object} [TB=object]
5711
5343
  * @typedef {object} QueryOptions
5712
5344
  * @property {string} [table]
5345
+ * @property {TableConnect?} [connect]
5713
5346
  * @property {T} fields
5714
5347
  * @property {string} [pseudo]
5715
5348
  * @property {((a: object, b?: object | boolean) => TB)?} [build]
5716
5349
  */
5717
5350
  /**
5718
5351
  * @template {Fields} T
5719
- * @template {object} [TB=object]
5352
+ * @template {object | never} [TB=object]
5720
5353
  * @implements {Queryable<T>}
5354
+ * @implements {Action<any[]>}
5721
5355
  */
5722
5356
  class Query extends Subquery {
5723
5357
  /**
@@ -5739,6 +5373,8 @@ class Query extends Subquery {
5739
5373
  }
5740
5374
  /** @readonly @type {string | undefined} */
5741
5375
 
5376
+ /** @readonly @type {TableConnect | null | undefined} */
5377
+
5742
5378
  /** @readonly @type {T} */
5743
5379
 
5744
5380
  /** @readonly @type {string} */
@@ -5766,6 +5402,7 @@ class Query extends Subquery {
5766
5402
  super();
5767
5403
  if (options instanceof Query) {
5768
5404
  this.table = options.table;
5405
+ this.connect = options.connect;
5769
5406
  this.fields = options.fields;
5770
5407
  this.pseudo = options.pseudo;
5771
5408
  this.#build = noBuild ? null : options.#build;
@@ -5776,11 +5413,13 @@ class Query extends Subquery {
5776
5413
  } else {
5777
5414
  const {
5778
5415
  table,
5416
+ connect,
5779
5417
  fields,
5780
5418
  pseudo,
5781
5419
  build
5782
5420
  } = options;
5783
5421
  this.table = table;
5422
+ this.connect = connect;
5784
5423
  this.fields = fields;
5785
5424
  this.pseudo = typeof pseudo === 'string' ? pseudo : '';
5786
5425
  this.#build = typeof build === 'function' ? build : null;
@@ -6190,6 +5829,41 @@ class Query extends Subquery {
6190
5829
  this.#options.lock = type === 'S' || type === 'X' ? type : null;
6191
5830
  return this;
6192
5831
  }
5832
+ async invoke(connect) {
5833
+ const selects = toSelect(this, true);
5834
+ const conn = await connect();
5835
+ return conn.select(selects);
5836
+ }
5837
+ /**
5838
+ * @param {string[]} fields
5839
+ * @param {Skip} [skip]
5840
+ * @returns {Action<FieldValue<T>[]>}
5841
+ */
5842
+ search(fields, skip) {
5843
+ return {
5844
+ connect: this.connect,
5845
+ invoke: async (connect, connection) => {
5846
+ const returnFields = Array.isArray(fields) ? fields : [];
5847
+ const conn = await connect();
5848
+ const result = search$1(conn, connection, this, returnFields, skip);
5849
+ return /** @type {any} */result;
5850
+ }
5851
+ };
5852
+ }
5853
+ /**
5854
+ * @param {Skip} [skip]
5855
+ * @returns {Action<(FieldValue<T> | TB)[]>}
5856
+ */
5857
+ find(skip) {
5858
+ return {
5859
+ connect: this.connect,
5860
+ invoke: async (connect, connection) => {
5861
+ const conn = await connect();
5862
+ const result = await search$1(conn, connection, this, true, skip);
5863
+ return result.map(it => conn.build(this, it, true));
5864
+ }
5865
+ };
5866
+ }
6193
5867
  }
6194
5868
 
6195
5869
  /** @import { Fields, IndexInfo, FieldDefine } from './types' */
@@ -7546,4 +7220,4 @@ function field(type, {
7546
7220
  };
7547
7221
  }
7548
7222
 
7549
- export { Build, CheckViolationError, Connection, ConnectionError, Create, Destroy, ForeignKeyViolationError, InvalidInputSyntaxError, Model, NotNullViolationError, OperatorMismatchError, PseudoDestroy, Query, Save, Scene, Submodel, UniqueViolationError, Where, index$1 as actions, afterCreate, afterCreateMany, afterDelete, afterUpdate, beforeCreate, beforeCreateMany, beforeDelete, beforeUpdate, bindHooks, coefficient, column, completelyDestroy, count, create, creating, decrement, defaultValue, field as define, _delete as delete, deleteReturn, deleted, deleting, destroy, destroyMany, divide, field$1 as field, find, first, getPrimaryFields, getPrimaryKeys, hooks, immutable, increment, index, insert, isDevelopment, isPseudo, mergeHooks, model, multiply, now, primary, prop, pseudo, pseudoDestroy, save, search, select, setDevelopment, sort, model as submodel, toBool, toNot, toPrimaries, toPrimary, uncreatable, undeleted, update, updateList, updateListReturn, updateReturn, updating, upsert, uuid, values, where, withDeleted };
7223
+ export { index$1 as Action, Build, CheckViolationError, Connection, ConnectionError, Create, Destroy, ForeignKeyViolationError, InvalidInputSyntaxError, Model, NotNullViolationError, OperatorMismatchError, PseudoDestroy, Query, Save, Scene, Submodel, Subquery, UniqueViolationError, Where, index$1 as actions, afterCreate, afterCreateMany, afterDelete, afterUpdate, beforeCreate, beforeCreateMany, beforeDelete, beforeUpdate, bindHooks, coefficient, column, completelyDestroy, count, create, creating, decrement, defaultValue, field as define, _delete as delete, deleteReturn, deleted, deleting, destroy, destroyMany, divide, field$1 as field, find, first, get, getPrimaryFields, getPrimaryKeys, hooks, immutable, increment, index, insert, isDevelopment, isPseudo, mergeHooks, model, multiply, now, primary, prop, pseudo, pseudoDestroy, save, search, select, setDevelopment, sort, model as submodel, toBool, toNot, toPrimaries, toPrimary, uncreatable, undeleted, update, updateList, updateListReturn, updateReturn, updating, upsert, uuid, values, where, withDeleted };