1.0.3 • Published 1 year ago

versioned-object v1.0.3

Weekly downloads
-
License
BSD-3-Clause
Repository
github
Last release
1 year ago

Versioned Object

Example

// Make sure to *NEVER* change an existing migration that is used in production. Always add new migrations.
const migrator = Migration.BaseMigration.addMigration(1, (v) => {
  return {
    /** always increment this */
    version: 1,
    bestCat: "unknown",
  };
})
  .addMigration(2, (v) => {
    return {
      version: 2,
      bestCat: v.bestCat === "unknown" ? "Meow" : v.bestCat,
    };
  })
  .build();

migrator.migrateToLatest({ version: 0 });