示例#1
0
// MoveToFinal with extract.
func MoveToFinalWE(db *mgo.Database, inp map[string][]string) error {
	r := map[string]interface{}{
		"comment_id": "must",
	}
	dat, err := extract.New(r).Extract(inp)
	if err != nil {
		return err
	}
	comment_id := basic.ToIdWithCare(dat["comment_id"])
	return MoveToFinal(db, comment_id)
}
示例#2
0
// returns nil if not found
func find(db *mgo.Database, content_id string) map[string]interface{} {
	content_bsonid := basic.ToIdWithCare(content_id)
	q := bson.M{
		"_id": content_bsonid,
	}
	var v interface{}
	err := db.C("contents").Find(q).One(&v)
	if err != nil {
		return nil
	}
	return basic.Convert(v).(map[string]interface{})
}
示例#3
0
func ToIdWithCare(id interface{}) bson.ObjectId {
	return basic.ToIdWithCare(id)
}