mirror of
https://gitlab.com/commento/commento.git
synced 2025-06-29 22:56:37 -04:00
api,db: add page attributes and thread locking
This commit is contained in:

committed by
Adhityaa Chandrasekar

parent
0a03a2c6fc
commit
299649cea2
24
api/page_new.go
Normal file
24
api/page_new.go
Normal file
@ -0,0 +1,24 @@
|
||||
package main
|
||||
|
||||
import ()
|
||||
|
||||
func pageNew(domain string, path string) error {
|
||||
// path can be empty
|
||||
if domain == "" {
|
||||
return errorMissingField
|
||||
}
|
||||
|
||||
statement := `
|
||||
INSERT INTO
|
||||
pages (domain, path)
|
||||
VALUES ($1, $2 )
|
||||
ON CONFLICT DO NOTHING;
|
||||
`
|
||||
_, err := db.Exec(statement, domain, path)
|
||||
if err != nil {
|
||||
logger.Errorf("error inserting new page: %v", err)
|
||||
return errorInternal
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user