package database import ( "time" ) // Writes a post to the database, returns the uid of the new post. func WritePost(author int, parent *int, title string, contents string, subreact string, image []byte, thumbnail []byte) (int, error) { var db = GetDb() var uid int row := db.QueryRow("INSERT INTO Posts "+ "(author, parent, time, subreact, title, contents, thumbnail, image) "+ "VALUES(?, ?, ?, ?, ?, ?, ?, ?) RETURNING Posts.uid;", author, parent, time.Now().Unix(), subreact, title, contents, thumbnail, image) if err := row.Scan(&uid); err != nil { return 0, err } return uid, nil }