The notification database module for golang.
It is using PostgreSQL as the database and will create a table:
CREATE TABLE IF NOT EXISTS notification (
id uuid primary key,
userid integer,
type smallint,
read boolean DEFAULT false,
at integer,
value jsonb
);
CREATE INDEX IF NOT EXISTS index_notification_userid ON notification (userid);
CREATE INDEX IF NOT EXISTS index_notification_at ON notification (at);
go get github.com/jackc/pgx
go get github.com/satori/go.uuid
or
glide install
First need to use the module with the pgx pool passed in:
err := kknotis.Use(pool)
Add notification:
err := kknotis.AddNotifications(3, 0, nil);
Get notifications:
result, err := kknotis.GetNotifications(3, 0);
Get unread notifications count:
count, err := GetUnreadCount(3);
Read one notification:
err := kknotis.ReadNotification(notisid);
Read all notifications:
err := kknotis.ReadAllNotifications(3);
Read notifications of a type
err := kknotis.ReadNotificationsByType(3, 0);
Delete one notification:
err := kknotis.DeleteNotification(notisid);
Delete all notifications:
err := kknotis.DeleteAllNotifications(3);
Delete notifications of a type
err := kknotis.DeleteNotificaitonByType(3, 0);