Download history to client
This commit is contained in:
parent
65a0225d74
commit
9506b89453
5 changed files with 249 additions and 75 deletions
47
node.go
47
node.go
|
|
@ -3,8 +3,8 @@ package main
|
|||
import (
|
||||
// External
|
||||
werr "git.gibonuddevalla.se/go/wrappederror"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/derektata/lorem/ipsum"
|
||||
"github.com/jmoiron/sqlx"
|
||||
|
||||
// Standard
|
||||
"database/sql"
|
||||
|
|
@ -248,6 +248,51 @@ func RetrieveNode(userID int, nodeUUID string) (node Node, err error) { // {{{
|
|||
|
||||
return
|
||||
} // }}}
|
||||
func RetrieveNodeHistory(userID int, nodeUUID string, offset int) (nodes []Node, hasMore bool, err error) { // {{{
|
||||
nodes = []Node{}
|
||||
|
||||
var rows *sqlx.Rows
|
||||
rows, err = db.Queryx(`
|
||||
SELECT
|
||||
uuid,
|
||||
user_id,
|
||||
name,
|
||||
created,
|
||||
updated,
|
||||
content,
|
||||
content_encrypted
|
||||
FROM node_history
|
||||
WHERE
|
||||
user_id = $1 AND
|
||||
uuid = $2
|
||||
LIMIT $3 OFFSET $4
|
||||
`,
|
||||
userID,
|
||||
nodeUUID,
|
||||
SYNC_PAGINATION+1,
|
||||
offset,
|
||||
)
|
||||
if err != nil {
|
||||
err = werr.Wrap(err)
|
||||
return
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
for rows.Next() {
|
||||
node := Node{}
|
||||
if err = rows.StructScan(&node); err != nil {
|
||||
err = werr.Wrap(err)
|
||||
return
|
||||
}
|
||||
nodes = append(nodes, node)
|
||||
}
|
||||
|
||||
if len(nodes) > SYNC_PAGINATION {
|
||||
hasMore = true
|
||||
nodes = nodes[0 : len(nodes)-1]
|
||||
}
|
||||
return
|
||||
} // }}}
|
||||
func NodeCrumbs(nodeUUID string) (nodes []Node, err error) { // {{{
|
||||
var rows *sqlx.Rows
|
||||
rows, err = db.Queryx(`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue