mirror of
https://gitlab.com/commento/commento.git
synced 2025-06-29 22:56:37 -04:00
api,db: add comments count endpoint
Closes https://gitlab.com/commento/commento-ce/issues/27
This commit is contained in:
15
db/20180923002745-comment-count.sql
Normal file
15
db/20180923002745-comment-count.sql
Normal file
@ -0,0 +1,15 @@
|
||||
ALTER TABLE pages
|
||||
ADD commentCount INTEGER NOT NULL DEFAULT 0;
|
||||
|
||||
CREATE OR REPLACE FUNCTION commentsInsertTriggerFunction() RETURNS TRIGGER AS $trigger$
|
||||
BEGIN
|
||||
UPDATE pages
|
||||
SET commentCount = commentCount + 1
|
||||
WHERE domain = new.domain AND path = new.path;
|
||||
|
||||
RETURN NEW;
|
||||
END;
|
||||
$trigger$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE TRIGGER commentsInsertTrigger AFTER INSERT ON comments
|
||||
FOR EACH ROW EXECUTE PROCEDURE commentsInsertTriggerFunction();
|
Reference in New Issue
Block a user