mirror of
https://github.com/nicksherron/bashhub-server.git
synced 2025-09-07 21:04:12 +08:00
internal/db: commandGet() support both sqlite and postgres
This commit is contained in:
parent
910144816a
commit
8ea0bea9be
1 changed files with 5 additions and 3 deletions
|
@ -126,16 +126,18 @@ func (cmd Command) commandGet() []Query {
|
|||
if connectionLimit != 1 {
|
||||
// postgres
|
||||
rows, err = DB.Query(`SELECT DISTINCT on ("command") command, "uuid", "created" from commands
|
||||
where "user_id" in (select "id" from users where "token" = $1) limit $2`, cmd.Token, cmd.Limit)
|
||||
where "user_id" in (select "id" from users where "token" = $1)
|
||||
order by "command", "created" desc limit $2`, cmd.Token, cmd.Limit)
|
||||
}else {
|
||||
// sqlite
|
||||
rows, err = DB.Query(`SELECT "command", "uuid", "created" from commands
|
||||
where "user_id" in (select "id" from users where "token" = $1)
|
||||
group by "command" limit $2`, cmd.Token, cmd.Limit)
|
||||
group by "command" order by "created" desc limit $2`, cmd.Token, cmd.Limit)
|
||||
}
|
||||
} else {
|
||||
rows, err = DB.Query(`SELECT "command", "uuid", "created" from commands
|
||||
where "user_id" in (select "id" from users where "token" = $1) limit $2`, cmd.Token, cmd.Limit)
|
||||
where "user_id" in (select "id" from users where "token" = $1)
|
||||
order by "created" desc limit $2`, cmd.Token, cmd.Limit)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Reference in a new issue