|
|
|
|
@ -9,13 +9,12 @@ import (
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func (d *DB) CreateUser(ctx context.Context, create *store.User) (*store.User, error) {
|
|
|
|
|
fields := []string{"`username`", "`role`", "`email`", "`nickname`", "`password_hash`"}
|
|
|
|
|
placeholder := []string{"?", "?", "?", "?", "?"}
|
|
|
|
|
args := []any{create.Username, create.Role, create.Email, create.Nickname, create.PasswordHash}
|
|
|
|
|
stmt := "INSERT INTO user (" + strings.Join(fields, ", ") + ") VALUES (" + strings.Join(placeholder, ", ") + ") RETURNING id, avatar_url, description, created_ts, updated_ts, row_status"
|
|
|
|
|
fields := []string{"`username`", "`role`", "`email`", "`nickname`", "`password_hash`, `avatar_url`"}
|
|
|
|
|
placeholder := []string{"?", "?", "?", "?", "?", "?"}
|
|
|
|
|
args := []any{create.Username, create.Role, create.Email, create.Nickname, create.PasswordHash, create.AvatarURL}
|
|
|
|
|
stmt := "INSERT INTO user (" + strings.Join(fields, ", ") + ") VALUES (" + strings.Join(placeholder, ", ") + ") RETURNING id, description, created_ts, updated_ts, row_status"
|
|
|
|
|
if err := d.db.QueryRowContext(ctx, stmt, args...).Scan(
|
|
|
|
|
&create.ID,
|
|
|
|
|
&create.AvatarURL,
|
|
|
|
|
&create.Description,
|
|
|
|
|
&create.CreatedTs,
|
|
|
|
|
&create.UpdatedTs,
|
|
|
|
|
|