-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #292 from evoluhq/improve-schema-dx
Improve table and database schema DX.
- Loading branch information
Showing
12 changed files
with
341 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
"@evolu/common": major | ||
--- | ||
|
||
Improve table and database schema DX. | ||
|
||
In the previous Evolu version, table and database schemas were created with `S.struct` and validated with createEvolu. Because of how the TypeScript compiler works, type errors were incomprehensible. | ||
|
||
We added two new helper functions to improve a DX: `table` and `database`. | ||
|
||
Previous schema definition: | ||
|
||
```ts | ||
const TodoTable = S.struct({ | ||
id: TodoId, | ||
title: NonEmptyString1000, | ||
}); | ||
const Database = S.struct({ | ||
todo: TodoTable, | ||
}); | ||
``` | ||
|
||
New schema definition: | ||
|
||
```ts | ||
const TodoTable = table({ | ||
id: TodoId, | ||
title: NonEmptyString1000, | ||
}); | ||
const Database = database({ | ||
todo: TodoTable, | ||
}); | ||
``` | ||
|
||
Those two helpers also detect missing ID columns and the usage of reserved columns. | ||
|
||
This update is a breaking change because reserved columns (createdAt, updatedAt, isDeleted) are created with `table` function now. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,8 @@ export { | |
canUseDom, | ||
cast, | ||
id, | ||
table, | ||
database, | ||
} from "@evolu/common"; | ||
export type { | ||
EvoluError, | ||
|
Oops, something went wrong.
631e033
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
evolu – ./
evolu-git-main-evolu.vercel.app
evolu.vercel.app
www.evolu.dev
evolu-evolu.vercel.app
evolu.dev