https://github.com/stefnotch/versioned-object
A simple JSON versioning schema with a fluent interface for adding migrations
https://github.com/stefnotch/versioned-object
Last synced: 4 days ago
JSON representation
A simple JSON versioning schema with a fluent interface for adding migrations
- Host: GitHub
- URL: https://github.com/stefnotch/versioned-object
- Owner: stefnotch
- License: bsd-3-clause
- Created: 2023-01-15T21:28:24.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-16T09:11:34.000Z (over 3 years ago)
- Last Synced: 2025-07-07T01:51:41.031Z (11 months ago)
- Language: TypeScript
- Size: 268 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Versioned Object
Example
```ts
// 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 });
```