mirror of
https://github.com/notherealmarco/WASAPhoto.git
synced 2025-05-05 12:22:35 +02:00
Solved some todo(s)
This commit is contained in:
parent
05acfb045f
commit
a3cf4f17f8
5 changed files with 27 additions and 30 deletions
|
@ -5,10 +5,9 @@ import (
|
|||
)
|
||||
|
||||
// Get user stream
|
||||
// todo implement stidx + offset
|
||||
func (db *appdbimpl) GetUserStream(uid string, start_index int, limit int) (*[]structures.Photo, error) {
|
||||
|
||||
// Get photos
|
||||
// Get photos from the database
|
||||
rows, err := db.c.Query(`SELECT "p"."user", "p"."id", "p"."date",
|
||||
(
|
||||
SELECT COUNT(*) AS "likes" FROM "likes" AS "l"
|
||||
|
|
|
@ -8,20 +8,16 @@ import (
|
|||
"github.com/notherealmarco/WASAPhoto/service/structures"
|
||||
)
|
||||
|
||||
//Check if user exists and if exists return the user id by username
|
||||
//todo
|
||||
|
||||
// Check if user exists
|
||||
func (db *appdbimpl) UserExists(uid string) (bool, error) { //todo: refactor code
|
||||
var name string
|
||||
err := db.c.QueryRow(`SELECT "name" FROM "users" WHERE "uid" = ?`, uid).Scan(&name)
|
||||
func (db *appdbimpl) UserExists(uid string) (bool, error) {
|
||||
|
||||
if db_errors.EmptySet(err) {
|
||||
return false, nil
|
||||
} else if err != nil {
|
||||
var cnt int
|
||||
err := db.c.QueryRow(`SELECT COUNT(*) FROM "users" WHERE "uid" = ?`, uid).Scan(&cnt)
|
||||
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
return cnt > 0, nil
|
||||
}
|
||||
|
||||
// Get user id by username
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue