Releases: ridafkih/schemix
v1.5.0
What's Changed
- Update onDelete and onUpdate referential actions by @zygopleural in #25
- Add composite uniqueness by @zygopleural in #23
- Allow unique enum fields by @zygopleural in #22
New Contributors
- @zygopleural made their first contribution in #25
Full Changelog: v1.4.0...v1.5.0
v1.4.0
v1.3.0
What's Changed
- feat: support recursive file search by @thwonghin in #17
New Contributors
- @thwonghin made their first contribution in #17
Full Changelog: v1.2.0...v1.3.0
v1.2.0
v1.1.2
Full Changelog: v0.6.0...v1.1.2
This release of Schemix drastically changes the functionality of the library.
Schema Indexing
Schemix will now automatically index the folders relative to the file in which the createSchema
function is called for three folders.
./models/
./mixins/
./enums/
It will pull the respective items from these folders, register them into the schema, and include it in the schema export.
Model Declaration
The way in which models, enums, and mixins are declared has changed. Now, you import createModel
, createEnum
, and createMixin
from the library itself, the name of the item will default to the file name, but an overriding name can be provided as the first parameter for these functions.
This means you no longer need to define the item in the index, import it into an external configuration file, and then import that configuration back into the index. This will all be managed automatically.
// models/User.model.ts
import { createModel } from "../../dist";
import PostModel from "./Post.model";
import UUIDMixin from "../mixins/UUID.mixin";
export default createModel((UserModel) => {
UserModel
.mixin(UUIDMixin)
.relation("friends", UserModel, { list: true, name: "friends" })
.relation("friendsRelation", UserModel, { list: true, name: "friends" })
.relation("posts", PostModel, { list: true });
});
The name in the aforementioned model will default to User
, as that is the name of the file. If we want to change it to UserModel
, for example, we can do so as follows.
// models/User.model.ts
// ...
export default createModel("UserModel", (UserModel) => {
UserModel
.mixin(UUIDMixin)
.relation("friends", UserModel, { list: true, name: "friends" })
.relation("friendsRelation", UserModel, { list: true, name: "friends" })
.relation("posts", PostModel, { list: true });
});
Contributions
If any issues are discovered, suggestions can be provided, etc., please get in contact! Feel free to open an issue, or PR!