Beispiel #1
0
// NewChanges creates a new change list and back fills the id.
func (db *DB) NewChanges(c *sitedb.Changes) error {
	now := time.Now()
	res, err := db.db.X(`insert into changes
		(owner, title, last_modify) values (?, ?, ?)`,
		c.Owner, c.Title, now.Unix(),
	)
	if err != nil {
		return err
	}

	id, err := res.LastInsertId()
	if err != nil {
		return err
	}
	c.LastModify = now
	c.ID = id
	return nil
}