func EnsureIndex(dbConn *mgo.Session, dbName string, collName string, index *mgo.Index) error { var err = dbConn.DB(dbName).C(collName).EnsureIndex(*index) if Panic && (err != nil) { panic(err) } return err }
func Insert(dbConn *mgo.Session, dbName string, collName string, recs ...interface{}) error { var err = dbConn.DB(dbName).C(collName).Insert(recs...) if Panic && (err != nil) { panic(err) } return err }
func DropDatabase(dbConn *mgo.Session, dbName string) error { var err = dbConn.DB(dbName).DropDatabase() if Panic && (err != nil) { panic(err) } return err }
func (su *StatsUnit) Find(sess *mgo.Session, col, uid, unitid string) os.Error { c := sess.DB(MGO_DB).C(col) if unitid == "" { return c.Find(bson.M{"userid": uid}).One(su) } return c.Find(bson.M{"userid": uid, "unitid": unitid}).One(su) }
func getPage(session *mgo.Session, title string) (result *Page, err error) { result = new(Page) c := session.DB(dbname).C("pages") err = c.Find(bson.M{"title": title}).One(result) return }
func Find(dbConn *mgo.Session, dbName string, collName string, query interface{}) *mgo.Query { return dbConn.DB(dbName).C(collName).Find(query) }
func (su *DigestwUser) Find(sess *mgo.Session, ns int64) *mgo.Iter { c := sess.DB(MGO_DB).C(MGO_COL_USER) return c.Find(bson.M{"nextseconds": bson.M{"$lt": ns}}).Limit(CRAWL_UNIT).Iter() }
func (su *DigestwUser) FindOne(sess *mgo.Session, sn string) os.Error { c := sess.DB(MGO_DB).C(MGO_COL_USER) return c.Find(bson.M{"screen_name": sn}).One(su) }
func (su *DigestwUser) Upsert(sess *mgo.Session) (interface{}, os.Error) { c := sess.DB(MGO_DB).C(MGO_COL_USER) return c.Upsert(bson.M{"screen_name": su.TwUser.Screen_Name}, su) }
func (su *StatsUnit) Upsert(sess *mgo.Session, col, uid, unitid string) (interface{}, os.Error) { c := sess.DB(MGO_DB).C(col) return c.Upsert(bson.M{"userid": uid, "unitid": unitid}, su) }