Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
1f79ee57
Commit
1f79ee57
authored
May 14, 2025
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: create user with avatar url for sqlite
parent
21935abe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
7 deletions
+5
-7
user.go
store/db/postgres/user.go
+1
-2
user.go
store/db/sqlite/user.go
+4
-5
No files found.
store/db/postgres/user.go
View file @
1f79ee57
...
@@ -11,10 +11,9 @@ import (
...
@@ -11,10 +11,9 @@ import (
func
(
d
*
DB
)
CreateUser
(
ctx
context
.
Context
,
create
*
store
.
User
)
(
*
store
.
User
,
error
)
{
func
(
d
*
DB
)
CreateUser
(
ctx
context
.
Context
,
create
*
store
.
User
)
(
*
store
.
User
,
error
)
{
fields
:=
[]
string
{
"username"
,
"role"
,
"email"
,
"nickname"
,
"password_hash"
,
"avatar_url"
}
fields
:=
[]
string
{
"username"
,
"role"
,
"email"
,
"nickname"
,
"password_hash"
,
"avatar_url"
}
args
:=
[]
any
{
create
.
Username
,
create
.
Role
,
create
.
Email
,
create
.
Nickname
,
create
.
PasswordHash
,
create
.
AvatarURL
}
args
:=
[]
any
{
create
.
Username
,
create
.
Role
,
create
.
Email
,
create
.
Nickname
,
create
.
PasswordHash
,
create
.
AvatarURL
}
stmt
:=
"INSERT INTO
\"
user
\"
("
+
strings
.
Join
(
fields
,
", "
)
+
") VALUES ("
+
placeholders
(
len
(
args
))
+
") RETURNING id,
avatar_url,
description, created_ts, updated_ts, row_status"
stmt
:=
"INSERT INTO
\"
user
\"
("
+
strings
.
Join
(
fields
,
", "
)
+
") VALUES ("
+
placeholders
(
len
(
args
))
+
") RETURNING id, description, created_ts, updated_ts, row_status"
if
err
:=
d
.
db
.
QueryRowContext
(
ctx
,
stmt
,
args
...
)
.
Scan
(
if
err
:=
d
.
db
.
QueryRowContext
(
ctx
,
stmt
,
args
...
)
.
Scan
(
&
create
.
ID
,
&
create
.
ID
,
&
create
.
AvatarURL
,
&
create
.
Description
,
&
create
.
Description
,
&
create
.
CreatedTs
,
&
create
.
CreatedTs
,
&
create
.
UpdatedTs
,
&
create
.
UpdatedTs
,
...
...
store/db/sqlite/user.go
View file @
1f79ee57
...
@@ -9,13 +9,12 @@ import (
...
@@ -9,13 +9,12 @@ import (
)
)
func
(
d
*
DB
)
CreateUser
(
ctx
context
.
Context
,
create
*
store
.
User
)
(
*
store
.
User
,
error
)
{
func
(
d
*
DB
)
CreateUser
(
ctx
context
.
Context
,
create
*
store
.
User
)
(
*
store
.
User
,
error
)
{
fields
:=
[]
string
{
"`username`"
,
"`role`"
,
"`email`"
,
"`nickname`"
,
"`password_hash`"
}
fields
:=
[]
string
{
"`username`"
,
"`role`"
,
"`email`"
,
"`nickname`"
,
"`password_hash`
, `avatar_url`
"
}
placeholder
:=
[]
string
{
"?"
,
"?"
,
"?"
,
"?"
,
"?"
}
placeholder
:=
[]
string
{
"?"
,
"?"
,
"?"
,
"?"
,
"?"
,
"?"
}
args
:=
[]
any
{
create
.
Username
,
create
.
Role
,
create
.
Email
,
create
.
Nickname
,
create
.
PasswordHash
}
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,
avatar_url,
description, created_ts, updated_ts, row_status"
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
(
if
err
:=
d
.
db
.
QueryRowContext
(
ctx
,
stmt
,
args
...
)
.
Scan
(
&
create
.
ID
,
&
create
.
ID
,
&
create
.
AvatarURL
,
&
create
.
Description
,
&
create
.
Description
,
&
create
.
CreatedTs
,
&
create
.
CreatedTs
,
&
create
.
UpdatedTs
,
&
create
.
UpdatedTs
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment