func (self *queryBase) OneID() (id bson.ObjectId, err error) { q, err := self.thisQuery.mongoQuery() if err != nil { return bson.ObjectId(""), err } var doc DocumentBase err = q.One(&doc) return doc.ID, err }
func (self *Ref) SetString(str string) error { switch len(str) { case 0, 12: self.ID = bson.ObjectId(str) case 24: self.ID = bson.ObjectIdHex(str) default: return errs.Format("Invalid string for bson.ObjectId: '%s'", str) } return nil }