Client UUID nodes from server sync count
This commit is contained in:
parent
dc010df448
commit
f33e5d54af
2 changed files with 61 additions and 3 deletions
34
node.go
34
node.go
|
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
// External
|
||||
werr "git.gibonuddevalla.se/go/wrappederror"
|
||||
"github.com/jmoiron/sqlx"
|
||||
|
||||
// Standard
|
||||
|
|
@ -183,6 +184,39 @@ func Nodes(userID, offset int, synced uint64, clientUUID string) (nodes []Node,
|
|||
|
||||
return
|
||||
} // }}}
|
||||
func NodesCount(userID int, synced uint64, clientUUID string) (count int, err error) { // {{{
|
||||
row := db.QueryRow(`
|
||||
SELECT
|
||||
COUNT(*)
|
||||
FROM
|
||||
public.node
|
||||
WHERE
|
||||
user_id = $1 AND
|
||||
client != $5 AND
|
||||
NOT history AND (
|
||||
created_seq > $4 OR
|
||||
updated_seq > $4 OR
|
||||
deleted_seq > $4
|
||||
)
|
||||
`,
|
||||
userID,
|
||||
synced,
|
||||
clientUUID,
|
||||
)
|
||||
row.Scan(&row)
|
||||
if err != nil {
|
||||
err = werr.Wrap(err).WithData(
|
||||
struct {
|
||||
UserID uint64
|
||||
Synced uint64
|
||||
ClientUUID string
|
||||
}{
|
||||
userID, synced, clientUUID,
|
||||
},
|
||||
)
|
||||
}
|
||||
return
|
||||
} // }}}
|
||||
func RetrieveNode(userID int, nodeUUID string) (node Node, err error) { // {{{
|
||||
var rows *sqlx.Row
|
||||
rows = db.QueryRowx(`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue