//appendHead add a infos generated from the record. func appendHead(tx *bolt.Tx, rec *record.Head) { if find(rec) { return } k := rec.ToKey() err := db.Put(tx, "recent", k, rec) if err != nil { log.Print(err) } }
//find finds records and returns index. returns -1 if not found. func find(rec *record.Head) bool { k := rec.ToKey() var r int err := db.DB.View(func(tx *bolt.Tx) error { var err error r, err = db.Count(tx, "recent", k) return err }) if err != nil { log.Print(err) } return r > 0 }