Skip to content

drkaka/kknotis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

kknotis Build Status Coverage Status

The notification database module for golang.

Database

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);

Dependence

go get github.com/jackc/pgx
go get github.com/satori/go.uuid

or

glide install

Usage

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);

About

The notification database module for golang.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages