import (
"github.com/totoval/framework/helpers/m"
"fmt"
)
func Create(){
user := User{
Username: ptr.String("totoval"),
Password: ptr.String("passw0rd"),
}
if err := m.H().Create(&user); err != nil{
panic(err)
}
fmt.Println(user)
}
import (
"github.com/totoval/framework/helpers/m"
"github.com/totoval/framework/helpers/ptr"
"github.com/totoval/framework/model/types/null"
"fmt"
)
func Save(){
user := User{
Id: 1,
Username: "totoval",
Password: "passw0rd",
Nickname: "mynick",
}
userModified := User{
Password: "passw0rd123", // modify password to `passw0rd123`
}
if err := m.H().Save(&user, userModified, User{
Nickname: null.String(), // set nickname to null
}); err != nil{
panic(err)
}
fmt.Println(user)
// the user will be saved as User{Id: 1, Username: "totoval", Password: "passw0rd123", Nickname: null}
}