npm dexie 4.0.0-alpha.1
Dexie v4.0.0-alpha.1

latest releases: 4.0.10, 4.0.9, 4.1.0-alpha.12...
2 years ago

The initial release on 4.0. Currently pretty much identical to 3.2.1+ but with:

  • More precise typings for Collection.modify() and Table.update() using template literal types for keyPaths.
  • Typings: Table.add() and Table.put() won't require methods to be present on the object to add. Allows for adding POJO objects rather than having to construct the full class to add a row.
  • Typings of Table generic: A property name can be used as 2nd generic argument (TKey) rather than the direct type. This will infer the key type from the type of that property and make it optional in Table.add() and Table.put() (see sample below)
  • New class exported class Entity that can be optionally used as a base class in order to resolve dependency issues when mapping tables to classes. A subclass of Entity has a private property this.db which is the Dexie instance it originates from. Entity subclasses are not meant to be constructed by application code.
    export class Friend extends Entity<FriendsDB> {
      id!: number;
      name!: string;
      age!: number;
    
      birthday() {
        return this.db.friends.update(this.id, friend => ++friend.age);
      }
    }
    
    export class FriendsDB extends Dexie {
      friends!: Table<Friend, 'id'>;
    
      constructor() {
        super("FriendsDB");
        this.version(1).stores({
          friends: '++id, name, age'
        });
        this.friends.mapToClass(Friend);
      }
    }

Don't miss a new dexie release

NewReleases is sending notifications on new releases.