Return true only when item added
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
9d81cc9a3a
commit
76edad3e8d
|
@ -204,7 +204,7 @@ func (p *postgresStream) AddItem(item microsub.Item) (bool, error) {
|
||||||
t = t2
|
t = t2
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = conn.ExecContext(context.Background(), `
|
result, err := conn.ExecContext(context.Background(), `
|
||||||
INSERT INTO "items" ("channel_id", "uid", "data", "published_at", "created_at")
|
INSERT INTO "items" ("channel_id", "uid", "data", "published_at", "created_at")
|
||||||
VALUES ($1, $2, $3, $4, DEFAULT)
|
VALUES ($1, $2, $3, $4, DEFAULT)
|
||||||
ON CONFLICT ON CONSTRAINT "items_uid_key" DO UPDATE SET "updated_at" = now()
|
ON CONFLICT ON CONSTRAINT "items_uid_key" DO UPDATE SET "updated_at" = now()
|
||||||
|
@ -212,7 +212,13 @@ ON CONFLICT ON CONSTRAINT "items_uid_key" DO UPDATE SET "updated_at" = now()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, fmt.Errorf("while adding item: %w", err)
|
return false, fmt.Errorf("while adding item: %w", err)
|
||||||
}
|
}
|
||||||
return true, nil
|
c, err := result.RowsAffected()
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("AddItem: rows affected %d\n", c)
|
||||||
|
return c > 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarkRead
|
// MarkRead
|
||||||
|
|
Loading…
Reference in New Issue
Block a user