-
-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide scanonly or insertonly #374
Comments
For now, you can split your model like this: type UserData struct {
bun.BaseModel `bun:"users"`
ID int64 `json:"id,string"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
type User struct {
UserData `bun:",inherit"`
ObjectID string `json:"objectId"`
} Not sure if we need |
Got it, so I'm misleading for the |
What does this "inherit" do? It is not documented anywhere! |
That's an alias for |
@vmihailenco Can we have a readonly and insertonly tag? readonly will be so helpful. |
I did not mean to close this. @imraan-go could you describe your use case so I have an idea how this will be used? |
"id" uuid NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY
@vmihailenco for this type of schenario |
@imraan-go it should be type Model struct {
ID UUD `bun:",pk,nullzero"`
} |
How can we select computed columns without insert/updating them? There seems to be no solution currently. |
My immediate usecase for insertonly would be for CreatedAt and CreatedBy fields. To ensure that they are only written to on creation of a resource, and to protect against devs making mistakes. |
This issue has been automatically marked as stale because it has not had activity in the last 30 days. If there is no update within the next 7 days, this issue will be closed. |
I have a generated column in PG table, and applied
scanonly
tag in model, here is the example code:I would expect the
object_id
appear in the query, but it doesn't.The text was updated successfully, but these errors were encountered: