func Findservbyid(id string) (u Serv, err error) { mConn := mymongo.Conn() defer mConn.Close() c := mConn.DB("anlintdb1").C("servads") err = c.Find(bson.M{"_id": bson.ObjectIdHex(id)}).One(&u) return }
func FinduserById() (u User) { mConn := mymongo.Conn() defer mConn.Close() c := mConn.DB("anlintdb1").C("users") c.Find(nil).One(u) return }
func Findlintbyid(id string) (u Lint, err error) { mConn := mymongo.Conn() defer mConn.Close() c := mConn.DB("anlintdb1").C("lints") err = c.FindId(bson.ObjectIdHex(id)).One(&u) return }
func Getallserv(lastdate time.Time) (personAll Servlist) { mConn := mymongo.Conn() defer mConn.Close() dbname := beego.AppConfig.String("mongodb::dbname") c := mConn.DB(dbname).C("servads") iter := c.Find(bson.M{"create_at": bson.M{"$lt": lastdate}, "status": 0}).Sort("-create_at").Skip(0).Limit(24).Iter() var result Serv for iter.Next(&result) { personAll.Servs = append(personAll.Servs, result) } return }
func Getlints(lastdate time.Time, cateid int) (personAll Lintlist) { mConn := mymongo.Conn() defer mConn.Close() dbname := beego.AppConfig.String("mongodb::dbname") c := mConn.DB(dbname).C("lints") iter := c.Find(bson.M{"create_at": bson.M{"$lt": lastdate}}).Sort("-create_at").Skip(0).Limit(24).Iter() var result Lint for iter.Next(&result) { personAll.Lints = append(personAll.Lints, result) } return }
func Getallusers() (personAll Men) { mConn := mymongo.Conn() defer mConn.Close() dbname := beego.AppConfig.String("mongodb::dbname") c := mConn.DB(dbname).C("users") iter := c.Find(nil).Iter() var result User for iter.Next(&result) { fmt.Printf("Result: %v\n", result.ID) personAll.Users = append(personAll.Users, result) } return }