Skip to content

isso database related code

ray edited this page Dec 11, 2018 · 1 revision

Comment

SQL

CREATE TABLE IF NOT EXISTS comments (
    tid REFERENCES threads(id),
    id INTEGER PRIMARY KEY,
    parent INTEGER,
    created FLOAT NOT NULL,
    modified FLOAT,
    mode INTEGER,
    remote_addr VARCHAR,
    text VARCHAR,
    author VARCHAR,
    email VARCHAR,
    website VARCHAR,
    likes INTEGER DEFAULT 0,
    dislikes INTEGER DEFAULT 0,
    voters BLOB NOT NULL,
    notification INTEGER DEFAULT 0
);

Golang type.

// Comment represent replies
type Comment struct {
    tid          int64
    ID           int64      `json:"id"`
    Parent       null.Int   `json:"parent"`
    Created      float64    `json:"created"`
    Modified     null.Float `json:"modified"`
    Mode         int64      `json:"mode"`
    remoteAddr   string
    Text         string      `json:"text"`
    Author       null.String `json:"author"`
    email        null.String
    Website      null.String `json:"website"`
    Likes        int64       `json:"likes"`
    Dislikes     int64       `json:"dislikes"`
    voters       []byte
    notification int64
    // not store in database.
    Hash string `json:"hash"`
}

Access ops

name in isso Comment type
add Add new comment to DB CURD
update Update comment id with values from data CURD
get Search for comment id and return a mapping of fields and values. CURD
reply_count Return comment count for main thread and all reply threads for one url. CURD
fetch Return comments for uri with mode. CURD
vote +1 a given comment. CURD-extra
count Return comment count for one ore more urls.. CURD-extra
count_modes Return comment mode counts for admin Admin
activate Activate comment id if pending. Admin
fetchall Return comments for admin with mode. Admin
delete Delete a comment. Admin
purge Remove comments older than delta. Admin
unsubscribe Turn off email notifications for replies to this comment. Notify
_remove_stale Compatible

Clone this wiki locally