+
Skip to content

drkaka/kkpm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

kkpm Build Status Coverage Status

The private message module for golang project. (IMPORTANT: The API and data structure may change!)

Database

It is using PostgreSQL as the database and will create a table:

CREATE TABLE IF NOT EXISTS private_msg (
  id uuid primary key,
  from_userid integer,
  to_userid integer,
  message text,
  read boolean,
  at integer
);
CREATE INDEX IF NOT EXISTS index_private_msg_to_userid ON private_msg (to_userid);
CREATE INDEX IF NOT EXISTS index_private_msg_from_userid ON private_msg (from_userid);
CREATE INDEX IF NOT EXISTS index_private_msg_at ON private_msg (at);

Dependence

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

Usage

First need to use the module with the pgx pool passed in:

err := kkpm.Use(pool)

Get the unread messages count:

count, err := GetUnreadCount(2);

Mark all messages from the user id as read:

err := ReadFrom(2, 3);

Get the messages sent:

result, err := kkpm.GetSentMessages(3, 0);

The second parameter is unixtime, the messages sent later than that will be got.

Get the messages received:

result, err := kkpm.GetReveivedMessages(3, 0);

The second parameter is unixtime, the messages received later than that will be got.

Get the messages between two people:

result, err := kkpm.GetPeerChat(3, 2, 0);

The third parameter is unixtime, the messages later than that will be got.

TODO

Delete

Manage

About

The private message module for golang project.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载