You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, guys. Thanks for this project be public.
I have a question about best case to uses with mssql.uniqueidentifier.
This is a small example of my struct and crud operations. I use bun to connect to database
type SomeStruct struct {
ID int `bun:"id"`
ExternalId mssql.UniqueIdentifier `bun:"externalid"`
IdPost int `bun:"id_post"`
IdAvatar int `bun:"id_avatar"`
}
func (someStruct *SomeStruct) MarshalJSON() ([]byte, error) {
type Alias SomeStruct
return json.Marshal(&struct {
ID string `json:"id"`
*Alias
}{
ID: someStruct.ExternalId.String(),
Alias: (*Alias)(someStruct),
})
}
I need use externalId as string everywhere at my project. And i need to cast mssql uniqueidentifier to string like i do at MarshalJson func. Is there a best practice to handle this without uses conversion everytime? I am thinking about change the unique identifier column to string. But i will lost much funcionalities of unique identifier be managed by sql server.
The text was updated successfully, but these errors were encountered:
For info about an established best practice with the go-mssqldb module, it might be better to ask at https://github.com/microsoft/go-mssqldb, or maybe even https://groups.google.com/g/golang-nuts or another broad resource listed at https://go.dev/help. The microsoft/go repository in particular is a fork of the Go compiler itself, so we might not know if there's a best practice already agreed upon by the community.
Hello, guys. Thanks for this project be public.
I have a question about best case to uses with mssql.uniqueidentifier.
This is a small example of my struct and crud operations. I use bun to connect to database
I need use externalId as string everywhere at my project. And i need to cast mssql uniqueidentifier to string like i do at MarshalJson func. Is there a best practice to handle this without uses conversion everytime? I am thinking about change the unique identifier column to string. But i will lost much funcionalities of unique identifier be managed by sql server.
The text was updated successfully, but these errors were encountered: