Exemple #1
0
func ReviewUpdateKotoba(id string, review bool, c *mgo.Collection) error {
	_id := bson.ObjectIdHex(id)
	kotoba := MongoKotoba{}
	c.Find(bson.M{"_id": _id}).One(&kotoba)
	if review {
		kotoba.IncLevel()
	} else {
		kotoba.DecLevel()
	}
	fmt.Println(kotoba)
	return c.UpdateId(_id, kotoba)
}
Exemple #2
0
func SaveEditKotoba(id string, word string, ll string, diff int, hatsuon string, h_ string,
	imi string, i_ string, c *mgo.Collection) (*MongoKotoba, error) {
	imis := SplitImi(imi)
	hatsuons := SplitHatsuon(hatsuon)
	labels := SplitLabels(ll)
	_id := bson.ObjectIdHex(id)
	kotoba := MongoKotoba{}
	c.Find(bson.M{"_id": _id}).One(&kotoba)
	fmt.Println(kotoba)
	kotoba.Goi = word
	kotoba.Hatsuons = *hatsuons
	kotoba.Imis = *imis
	kotoba.Labels = *labels
	kotoba.Imi_ = i_
	kotoba.Hatsuon_ = h_
	kotoba.Difficulty = diff
	fmt.Println(kotoba)
	return &kotoba, c.UpdateId(kotoba.Id, &kotoba)
}
Exemple #3
0
func SaveKotoba(mk *MongoKotoba, c *mgo.Collection) error {
	return c.UpdateId(mk.Id, mk)
}