Replies: 2 comments
-
What do you think of the idea? In my case, I want to use go layer defined custom enum type (that's stored in RDB's string type column) without caring if it's jet generated or user defined. For example:
// my_custom_users.go
package model
type UserType string
const (
UserTypeAdmin UserType = "admin"
UserTypeManager UserType = "manger"
) // ===== then we can write:
var users []model.User
SELECT(Users.AllColumns).
FROM(Users).
WHERE(AND(
Users.Type.EQ(model.UserSubscriptionPlan_Pro), // <= this one is generated by jet from postgres'enum type
Users.Type.EQ(model.UserTypeAdmin), // <= manually added enums can be referenced like other enums with model.*
)).
Query(db, &users)
// ===== as opposed to:
var users []model.User
SELECT(Users.AllColumns).
FROM(Users).
WHERE(AND(
Users.Type.EQ(model.UserSubscriptionPlan_Pro),
Users.Type.EQ(custom_package_somewhere_else.UserTypeAdmin), // <= we need to be aware of where the enum comes from
)).
Query(db, &users) The generation command will be like:
I'm gonna create a PR if it's looking good. |
Beta Was this translation helpful? Give feedback.
-
Shouldn't this be
My preference is to have separate packages. Because this way, I have a visual distinction between auto-generated and custom packages. |
Beta Was this translation helpful? Give feedback.
-
When customizing generated models following the doc, it'd be nice if the user-added custom models resided in the same packages as the jet model, so that we don't have to discriminate the import path depending on custom or not. But currently the generator deletes the whole destination directory, so any files added under
model/*
are deleted.What do you think of adding an option to keep some of the files under destination directory, for example:
filepath.Glob
of the files to keep (or delete)Beta Was this translation helpful? Give feedback.
All reactions