@bjnstnkvc/db 2.0.1 → 2.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/README.md CHANGED
@@ -835,6 +835,7 @@ await DB.table<User>('users').where('id', 1).increment('visits');
835
835
  await DB.table<User>('users').where('id', 1).decrement('credits', 5);
836
836
 
837
837
  await DB.table<User>('users').where('role', 'guest').delete();
838
+ await DB.table<User>('users').oldest('created_at').limit(100).delete();
838
839
  await DB.table<User>('users').truncate();
839
840
  ```
840
841
 
@@ -851,9 +852,10 @@ enforce anything else. Any other column throws `SchemaException`.
851
852
 
852
853
  The key path may not be updated, so `update`, `upsert` and `increment` all refuse it.
853
854
 
854
- `update` and `delete` honour `limit` and `offset` in the order the plan scans, which is index order
855
- when an index drives the query and key order otherwise. Pair them with an indexed `orderBy` if you
856
- need a defined order.
855
+ `update`, `delete`, `increment` and `decrement` honor `orderBy` together with `limit` and
856
+ `offset`, so they touch the same records a read of the query would return, whether or not an index
857
+ serves the order. Without an `orderBy`, they follow the order the plan scans, which is index order
858
+ when an index drives the query and key order otherwise.
857
859
 
858
860
  > Modeled on Laravel's [Database: Query Builder](https://laravel.com/docs/12.x/queries). The method
859
861
  > names and their semantics match, and every terminal is asynchronous because IndexedDB is.
@@ -1117,22 +1119,23 @@ DB.onQueryExecuted((event: QueryExecuted): void => {
1117
1119
  });
1118
1120
  ```
1119
1121
 
1120
- | Key | Class | Carries |
1121
- |---------------------------|-------------------------|----------------------------------------------------------------------------------------|
1122
- | `query` | `QueryExecuted` | `connection`, `table`, `plan`, `constraints`, `orders`, `limit`, `duration`, `records` |
1123
- | `transaction-beginning` | `TransactionBeginning` | `connection` |
1124
- | `transaction-committed` | `TransactionCommitted` | `connection` |
1125
- | `transaction-rolled-back` | `TransactionRolledBack` | `connection`, `reason` |
1126
- | `migrations-started` | `MigrationsStarted` | `connection`, `migrations` |
1127
- | `migration-started` | `MigrationStarted` | `migration` |
1128
- | `migration-ended` | `MigrationEnded` | `migration` |
1129
- | `migrations-ended` | `MigrationsEnded` | `connection`, `migrations` |
1130
- | `no-pending-migrations` | `NoPendingMigrations` | `connection` |
1131
- | `seeding-started` | `SeedingStarted` | `connection`, `seeders` |
1132
- | `seeder-started` | `SeederStarted` | `seeder` |
1133
- | `seeder-ended` | `SeederEnded` | `seeder` |
1134
- | `seeding-ended` | `SeedingEnded` | `connection`, `seeders` |
1135
- | `database-blocked` | `DatabaseBlocked` | `database` |
1122
+ | Key | Class | Carries |
1123
+ |----------------------------|--------------------------|----------------------------------------------------------------------------------------|
1124
+ | `query` | `QueryExecuted` | `connection`, `table`, `plan`, `constraints`, `orders`, `limit`, `duration`, `records` |
1125
+ | `transaction-beginning` | `TransactionBeginning` | `connection` |
1126
+ | `transaction-committed` | `TransactionCommitted` | `connection` |
1127
+ | `transaction-rolled-back` | `TransactionRolledBack` | `connection`, `reason` |
1128
+ | `migrations-started` | `MigrationsStarted` | `connection`, `migrations` |
1129
+ | `migration-started` | `MigrationStarted` | `migration` |
1130
+ | `migration-ended` | `MigrationEnded` | `migration` |
1131
+ | `migrations-ended` | `MigrationsEnded` | `connection`, `migrations` |
1132
+ | `no-pending-migrations` | `NoPendingMigrations` | `connection` |
1133
+ | `seeding-started` | `SeedingStarted` | `connection`, `seeders` |
1134
+ | `seeder-started` | `SeederStarted` | `seeder` |
1135
+ | `seeder-ended` | `SeederEnded` | `seeder` |
1136
+ | `seeding-ended` | `SeedingEnded` | `connection`, `seeders` |
1137
+ | `database-blocked` | `DatabaseBlocked` | `database` |
1138
+ | `database-version-changed` | `DatabaseVersionChanged` | `database`, `version` |
1136
1139
 
1137
1140
  A connection with no seeders announces nothing, so `seeding-started` firing always means at least
1138
1141
  one seeder is about to run.
@@ -1181,9 +1184,21 @@ IndexedDB is shared across tabs, which produces two situations worth handling:
1181
1184
  - Another tab holds an older version open, blocking an upgrade. The connection emits
1182
1185
  `database-blocked` and rejects with `DatabaseBlockedException`, so you can ask the user to close
1183
1186
  the other tabs.
1184
- - Another tab upgrades the database. The connection closes its own handle so it does not block that
1185
- upgrade. If the other tab is running newer code with more migrations, this tab can no longer open
1186
- the database and reports `MigrationMismatchException`, so reload the page.
1187
+ - Another tab upgrades or deletes the database. The connection closes its own handle so it does not
1188
+ block that tab, then emits `database-version-changed`. Its `version` is the version the other tab
1189
+ is opening, or `null` when it is deleting the database.
1190
+
1191
+ The other tab is usually running newer code with more migrations, after a deploy. This tab can no
1192
+ longer open the database, and its next query would reject with `MigrationMismatchException`. Reload
1193
+ the page when the event arrives, rather than querying again:
1194
+
1195
+ ```ts
1196
+ DB.onDatabaseVersionChanged((event: DatabaseVersionChanged): void => {
1197
+ if (confirm('A new version is available. Reload now?')) {
1198
+ location.reload();
1199
+ }
1200
+ });
1201
+ ```
1187
1202
 
1188
1203
  ### Connections
1189
1204
 
package/dist/main.cjs CHANGED
@@ -30,6 +30,7 @@ __export(main_exports, {
30
30
  DatabaseBlocked: () => DatabaseBlocked,
31
31
  DatabaseBlockedException: () => DatabaseBlockedException,
32
32
  DatabaseManager: () => DatabaseManager,
33
+ DatabaseVersionChanged: () => DatabaseVersionChanged,
33
34
  Grouping: () => Grouping,
34
35
  Join: () => Join,
35
36
  Migration: () => Migration,
@@ -690,6 +691,38 @@ var DatabaseBlocked = class extends Event {
690
691
  }
691
692
  };
692
693
 
694
+ // src/events/DatabaseVersionChanged.ts
695
+ var DatabaseVersionChanged = class extends Event {
696
+ /**
697
+ * The name of the database.
698
+ */
699
+ #database;
700
+ /**
701
+ * The version the other tab is opening, or null when it is deleting the database.
702
+ */
703
+ #version;
704
+ /**
705
+ * Create a new Database Version Changed event instance.
706
+ */
707
+ constructor(database, version) {
708
+ super("db:database-version-changed");
709
+ this.#database = database;
710
+ this.#version = version;
711
+ }
712
+ /**
713
+ * Get the name of the database.
714
+ */
715
+ get database() {
716
+ return this.#database;
717
+ }
718
+ /**
719
+ * Get the version the other tab is opening, or null when it is deleting the database.
720
+ */
721
+ get version() {
722
+ return this.#version;
723
+ }
724
+ };
725
+
693
726
  // src/events/MigrationEnded.ts
694
727
  var MigrationEnded = class extends Event {
695
728
  /**
@@ -2910,7 +2943,7 @@ var Builder = class _Builder {
2910
2943
  }
2911
2944
  }
2912
2945
  /**
2913
- * Apply a change to every record matching the query, in the order the plan scans them.
2946
+ * Apply a change to every record matching the query, in the order the query asks for.
2914
2947
  */
2915
2948
  async #modify(apply) {
2916
2949
  const schema = await this.#connection.schema(this.#table);
@@ -2919,8 +2952,20 @@ var Builder = class _Builder {
2919
2952
  const started = performance.now();
2920
2953
  const matches = Predicate.compile(plan.residual);
2921
2954
  const ceiling = this.#limit === null ? null : this.#offset + this.#limit;
2955
+ const collects = !plan.ordered && this.#orders.length > 0 && (this.#limit !== null || this.#offset > 0);
2922
2956
  let seen = 0;
2923
2957
  let affected = 0;
2958
+ if (collects) {
2959
+ const collected = plan.values === null ? await this.#cursored(store, plan, matches) : await this.#points(store, plan, matches);
2960
+ for (const entry of this.#paged(this.#sorted(collected))) {
2961
+ await Request.walk(store.openCursor(IDBKeyRange.only(entry.key)), (cursor) => {
2962
+ apply(cursor);
2963
+ affected++;
2964
+ });
2965
+ }
2966
+ this.#emit(Planner.describe(plan), started, affected);
2967
+ return affected;
2968
+ }
2924
2969
  const visit = (cursor) => {
2925
2970
  if (!matches(cursor.value)) {
2926
2971
  return true;
@@ -2937,6 +2982,9 @@ var Builder = class _Builder {
2937
2982
  await Request.walk(source.openCursor(plan.range, plan.direction), visit);
2938
2983
  } else {
2939
2984
  for (const value of plan.values) {
2985
+ if (ceiling !== null && seen >= ceiling) {
2986
+ break;
2987
+ }
2940
2988
  const source = plan.index === null ? store : store.index(plan.index);
2941
2989
  await Request.walk(source.openCursor(IDBKeyRange.only(value)), visit);
2942
2990
  }
@@ -3792,7 +3840,10 @@ var Connection = class {
3792
3840
  Migrator.verify(ran, Migrator.names(this.migrations));
3793
3841
  this.#schemas = new Map(registry.map((schema) => [schema.table, schema]));
3794
3842
  this.#database = database;
3795
- database.onversionchange = () => this.disconnect();
3843
+ database.onversionchange = (event) => {
3844
+ this.disconnect();
3845
+ Dispatcher.dispatch(new DatabaseVersionChanged(this.#config.database, event.newVersion));
3846
+ };
3796
3847
  return database;
3797
3848
  }
3798
3849
  };
@@ -4028,6 +4079,12 @@ var DatabaseManager = class {
4028
4079
  static onDatabaseBlocked(listener, options) {
4029
4080
  this.listen("database-blocked", listener, options);
4030
4081
  }
4082
+ /**
4083
+ * Register a listener on the "database-version-changed" event.
4084
+ */
4085
+ static onDatabaseVersionChanged(listener, options) {
4086
+ this.listen("database-version-changed", listener, options);
4087
+ }
4031
4088
  /**
4032
4089
  * Register a listener on the "seeding-started" event.
4033
4090
  */
@@ -4357,6 +4414,7 @@ var Seeder = class {
4357
4414
  DatabaseBlocked,
4358
4415
  DatabaseBlockedException,
4359
4416
  DatabaseManager,
4417
+ DatabaseVersionChanged,
4360
4418
  Grouping,
4361
4419
  Join,
4362
4420
  Migration,
package/dist/main.d.cts CHANGED
@@ -861,6 +861,22 @@ declare class DatabaseBlocked extends Event {
861
861
  get database(): string;
862
862
  }
863
863
 
864
+ declare class DatabaseVersionChanged extends Event {
865
+ #private;
866
+ /**
867
+ * Create a new Database Version Changed event instance.
868
+ */
869
+ constructor(database: string, version: number | null);
870
+ /**
871
+ * Get the name of the database.
872
+ */
873
+ get database(): string;
874
+ /**
875
+ * Get the version the other tab is opening, or null when it is deleting the database.
876
+ */
877
+ get version(): number | null;
878
+ }
879
+
864
880
  declare class MigrationEnded extends Event {
865
881
  #private;
866
882
  /**
@@ -1067,6 +1083,7 @@ declare class TransactionRolledBack extends Event {
1067
1083
 
1068
1084
  type DatabaseEvent = {
1069
1085
  'database-blocked': DatabaseBlocked;
1086
+ 'database-version-changed': DatabaseVersionChanged;
1070
1087
  'migration-ended': MigrationEnded;
1071
1088
  'migration-started': MigrationStarted;
1072
1089
  'migrations-ended': MigrationsEnded;
@@ -1205,6 +1222,10 @@ declare class DatabaseManager {
1205
1222
  * Register a listener on the "database-blocked" event.
1206
1223
  */
1207
1224
  static onDatabaseBlocked(listener: (event: DatabaseBlocked) => void, options?: ListenOptions): void;
1225
+ /**
1226
+ * Register a listener on the "database-version-changed" event.
1227
+ */
1228
+ static onDatabaseVersionChanged(listener: (event: DatabaseVersionChanged) => void, options?: ListenOptions): void;
1208
1229
  /**
1209
1230
  * Register a listener on the "seeding-started" event.
1210
1231
  */
@@ -1386,4 +1407,4 @@ declare class UniqueConstraintViolationException extends Error {
1386
1407
  constructor(table: string, index: string);
1387
1408
  }
1388
1409
 
1389
- export { type Aggregated, type Aggregation, type Aggregations, Blueprint, Builder, CheckConstraintViolationException, ColumnDefinition, type ColumnSchema, type ColumnType, type Conjunction, Connection, type ConnectionConfig, ConnectionNotConfiguredException, type Constraint, DatabaseManager as DB, DatabaseBlocked, DatabaseBlockedException, type DatabaseConfig, type DatabaseEvent, type DatabaseEventListener, DatabaseManager, type DatePart, type Direction, type Enumerable, type FreshOptions, type Grouped, Grouping, type IndexSchema, Join, type JoinClause, type JoinCondition, type JoinType, type Key, type ListenOptions, Migration, type MigrationConstructor, MigrationEnded, MigrationMismatchException, MigrationStarted, type MigrationStatus, MigrationTransactionClosedException, MigrationsEnded, MigrationsStarted, MultipleRecordsFoundException, NoPendingMigrations, NotNullConstraintViolationException, type Operator, type Order, type Paginated, type Plan, type Projection, QueryExecuted, type QueryLogEntry, QuotaExceededException, RecordsNotFoundException, ReservedTableException, Schema, SchemaException, Seeder, type SeederConstructor, SeederEnded, SeederStarted, SeedingEnded, SeedingStarted, TableNotFoundException, type TableSchema, Transaction, TransactionBeginning, TransactionCommitted, type TransactionOptions, TransactionRolledBack, UniqueConstraintViolationException };
1410
+ export { type Aggregated, type Aggregation, type Aggregations, Blueprint, Builder, CheckConstraintViolationException, ColumnDefinition, type ColumnSchema, type ColumnType, type Conjunction, Connection, type ConnectionConfig, ConnectionNotConfiguredException, type Constraint, DatabaseManager as DB, DatabaseBlocked, DatabaseBlockedException, type DatabaseConfig, type DatabaseEvent, type DatabaseEventListener, DatabaseManager, DatabaseVersionChanged, type DatePart, type Direction, type Enumerable, type FreshOptions, type Grouped, Grouping, type IndexSchema, Join, type JoinClause, type JoinCondition, type JoinType, type Key, type ListenOptions, Migration, type MigrationConstructor, MigrationEnded, MigrationMismatchException, MigrationStarted, type MigrationStatus, MigrationTransactionClosedException, MigrationsEnded, MigrationsStarted, MultipleRecordsFoundException, NoPendingMigrations, NotNullConstraintViolationException, type Operator, type Order, type Paginated, type Plan, type Projection, QueryExecuted, type QueryLogEntry, QuotaExceededException, RecordsNotFoundException, ReservedTableException, Schema, SchemaException, Seeder, type SeederConstructor, SeederEnded, SeederStarted, SeedingEnded, SeedingStarted, TableNotFoundException, type TableSchema, Transaction, TransactionBeginning, TransactionCommitted, type TransactionOptions, TransactionRolledBack, UniqueConstraintViolationException };
package/dist/main.d.ts CHANGED
@@ -861,6 +861,22 @@ declare class DatabaseBlocked extends Event {
861
861
  get database(): string;
862
862
  }
863
863
 
864
+ declare class DatabaseVersionChanged extends Event {
865
+ #private;
866
+ /**
867
+ * Create a new Database Version Changed event instance.
868
+ */
869
+ constructor(database: string, version: number | null);
870
+ /**
871
+ * Get the name of the database.
872
+ */
873
+ get database(): string;
874
+ /**
875
+ * Get the version the other tab is opening, or null when it is deleting the database.
876
+ */
877
+ get version(): number | null;
878
+ }
879
+
864
880
  declare class MigrationEnded extends Event {
865
881
  #private;
866
882
  /**
@@ -1067,6 +1083,7 @@ declare class TransactionRolledBack extends Event {
1067
1083
 
1068
1084
  type DatabaseEvent = {
1069
1085
  'database-blocked': DatabaseBlocked;
1086
+ 'database-version-changed': DatabaseVersionChanged;
1070
1087
  'migration-ended': MigrationEnded;
1071
1088
  'migration-started': MigrationStarted;
1072
1089
  'migrations-ended': MigrationsEnded;
@@ -1205,6 +1222,10 @@ declare class DatabaseManager {
1205
1222
  * Register a listener on the "database-blocked" event.
1206
1223
  */
1207
1224
  static onDatabaseBlocked(listener: (event: DatabaseBlocked) => void, options?: ListenOptions): void;
1225
+ /**
1226
+ * Register a listener on the "database-version-changed" event.
1227
+ */
1228
+ static onDatabaseVersionChanged(listener: (event: DatabaseVersionChanged) => void, options?: ListenOptions): void;
1208
1229
  /**
1209
1230
  * Register a listener on the "seeding-started" event.
1210
1231
  */
@@ -1386,4 +1407,4 @@ declare class UniqueConstraintViolationException extends Error {
1386
1407
  constructor(table: string, index: string);
1387
1408
  }
1388
1409
 
1389
- export { type Aggregated, type Aggregation, type Aggregations, Blueprint, Builder, CheckConstraintViolationException, ColumnDefinition, type ColumnSchema, type ColumnType, type Conjunction, Connection, type ConnectionConfig, ConnectionNotConfiguredException, type Constraint, DatabaseManager as DB, DatabaseBlocked, DatabaseBlockedException, type DatabaseConfig, type DatabaseEvent, type DatabaseEventListener, DatabaseManager, type DatePart, type Direction, type Enumerable, type FreshOptions, type Grouped, Grouping, type IndexSchema, Join, type JoinClause, type JoinCondition, type JoinType, type Key, type ListenOptions, Migration, type MigrationConstructor, MigrationEnded, MigrationMismatchException, MigrationStarted, type MigrationStatus, MigrationTransactionClosedException, MigrationsEnded, MigrationsStarted, MultipleRecordsFoundException, NoPendingMigrations, NotNullConstraintViolationException, type Operator, type Order, type Paginated, type Plan, type Projection, QueryExecuted, type QueryLogEntry, QuotaExceededException, RecordsNotFoundException, ReservedTableException, Schema, SchemaException, Seeder, type SeederConstructor, SeederEnded, SeederStarted, SeedingEnded, SeedingStarted, TableNotFoundException, type TableSchema, Transaction, TransactionBeginning, TransactionCommitted, type TransactionOptions, TransactionRolledBack, UniqueConstraintViolationException };
1410
+ export { type Aggregated, type Aggregation, type Aggregations, Blueprint, Builder, CheckConstraintViolationException, ColumnDefinition, type ColumnSchema, type ColumnType, type Conjunction, Connection, type ConnectionConfig, ConnectionNotConfiguredException, type Constraint, DatabaseManager as DB, DatabaseBlocked, DatabaseBlockedException, type DatabaseConfig, type DatabaseEvent, type DatabaseEventListener, DatabaseManager, DatabaseVersionChanged, type DatePart, type Direction, type Enumerable, type FreshOptions, type Grouped, Grouping, type IndexSchema, Join, type JoinClause, type JoinCondition, type JoinType, type Key, type ListenOptions, Migration, type MigrationConstructor, MigrationEnded, MigrationMismatchException, MigrationStarted, type MigrationStatus, MigrationTransactionClosedException, MigrationsEnded, MigrationsStarted, MultipleRecordsFoundException, NoPendingMigrations, NotNullConstraintViolationException, type Operator, type Order, type Paginated, type Plan, type Projection, QueryExecuted, type QueryLogEntry, QuotaExceededException, RecordsNotFoundException, ReservedTableException, Schema, SchemaException, Seeder, type SeederConstructor, SeederEnded, SeederStarted, SeedingEnded, SeedingStarted, TableNotFoundException, type TableSchema, Transaction, TransactionBeginning, TransactionCommitted, type TransactionOptions, TransactionRolledBack, UniqueConstraintViolationException };
package/dist/main.js CHANGED
@@ -626,6 +626,38 @@ var DatabaseBlocked = class extends Event {
626
626
  }
627
627
  };
628
628
 
629
+ // src/events/DatabaseVersionChanged.ts
630
+ var DatabaseVersionChanged = class extends Event {
631
+ /**
632
+ * The name of the database.
633
+ */
634
+ #database;
635
+ /**
636
+ * The version the other tab is opening, or null when it is deleting the database.
637
+ */
638
+ #version;
639
+ /**
640
+ * Create a new Database Version Changed event instance.
641
+ */
642
+ constructor(database, version) {
643
+ super("db:database-version-changed");
644
+ this.#database = database;
645
+ this.#version = version;
646
+ }
647
+ /**
648
+ * Get the name of the database.
649
+ */
650
+ get database() {
651
+ return this.#database;
652
+ }
653
+ /**
654
+ * Get the version the other tab is opening, or null when it is deleting the database.
655
+ */
656
+ get version() {
657
+ return this.#version;
658
+ }
659
+ };
660
+
629
661
  // src/events/MigrationEnded.ts
630
662
  var MigrationEnded = class extends Event {
631
663
  /**
@@ -2846,7 +2878,7 @@ var Builder = class _Builder {
2846
2878
  }
2847
2879
  }
2848
2880
  /**
2849
- * Apply a change to every record matching the query, in the order the plan scans them.
2881
+ * Apply a change to every record matching the query, in the order the query asks for.
2850
2882
  */
2851
2883
  async #modify(apply) {
2852
2884
  const schema = await this.#connection.schema(this.#table);
@@ -2855,8 +2887,20 @@ var Builder = class _Builder {
2855
2887
  const started = performance.now();
2856
2888
  const matches = Predicate.compile(plan.residual);
2857
2889
  const ceiling = this.#limit === null ? null : this.#offset + this.#limit;
2890
+ const collects = !plan.ordered && this.#orders.length > 0 && (this.#limit !== null || this.#offset > 0);
2858
2891
  let seen = 0;
2859
2892
  let affected = 0;
2893
+ if (collects) {
2894
+ const collected = plan.values === null ? await this.#cursored(store, plan, matches) : await this.#points(store, plan, matches);
2895
+ for (const entry of this.#paged(this.#sorted(collected))) {
2896
+ await Request.walk(store.openCursor(IDBKeyRange.only(entry.key)), (cursor) => {
2897
+ apply(cursor);
2898
+ affected++;
2899
+ });
2900
+ }
2901
+ this.#emit(Planner.describe(plan), started, affected);
2902
+ return affected;
2903
+ }
2860
2904
  const visit = (cursor) => {
2861
2905
  if (!matches(cursor.value)) {
2862
2906
  return true;
@@ -2873,6 +2917,9 @@ var Builder = class _Builder {
2873
2917
  await Request.walk(source.openCursor(plan.range, plan.direction), visit);
2874
2918
  } else {
2875
2919
  for (const value of plan.values) {
2920
+ if (ceiling !== null && seen >= ceiling) {
2921
+ break;
2922
+ }
2876
2923
  const source = plan.index === null ? store : store.index(plan.index);
2877
2924
  await Request.walk(source.openCursor(IDBKeyRange.only(value)), visit);
2878
2925
  }
@@ -3728,7 +3775,10 @@ var Connection = class {
3728
3775
  Migrator.verify(ran, Migrator.names(this.migrations));
3729
3776
  this.#schemas = new Map(registry.map((schema) => [schema.table, schema]));
3730
3777
  this.#database = database;
3731
- database.onversionchange = () => this.disconnect();
3778
+ database.onversionchange = (event) => {
3779
+ this.disconnect();
3780
+ Dispatcher.dispatch(new DatabaseVersionChanged(this.#config.database, event.newVersion));
3781
+ };
3732
3782
  return database;
3733
3783
  }
3734
3784
  };
@@ -3964,6 +4014,12 @@ var DatabaseManager = class {
3964
4014
  static onDatabaseBlocked(listener, options) {
3965
4015
  this.listen("database-blocked", listener, options);
3966
4016
  }
4017
+ /**
4018
+ * Register a listener on the "database-version-changed" event.
4019
+ */
4020
+ static onDatabaseVersionChanged(listener, options) {
4021
+ this.listen("database-version-changed", listener, options);
4022
+ }
3967
4023
  /**
3968
4024
  * Register a listener on the "seeding-started" event.
3969
4025
  */
@@ -4292,6 +4348,7 @@ export {
4292
4348
  DatabaseBlocked,
4293
4349
  DatabaseBlockedException,
4294
4350
  DatabaseManager,
4351
+ DatabaseVersionChanged,
4295
4352
  Grouping,
4296
4353
  Join,
4297
4354
  Migration,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bjnstnkvc/db",
3
- "version": "2.0.1",
3
+ "version": "2.1.0",
4
4
  "description": "TypeScript database layer for IndexedDB with an API modeled on Laravel.",
5
5
  "type": "module",
6
6
  "main": "./dist/main.cjs",