// collection returns a mgo.Collection representation for given collection name and session
979451
func (s *DbSession) collection(collectionName string) *mgo.Collection {
	return s.Session.DB(s.db.Config.DBName).C(collectionName)
}
408017
func (db *database) GetCollectionFor(modelUUID, name string) (mongo.Collection, SessionCloser) {
	newDb, dbcloser := db.CopyForModel(modelUUID)
	collection, closer := newDb.GetCollection(name)
	return collection, func() {
		closer()
		dbcloser()
	}
}
108131
func (m *MockDatabase) GetRawCollection(arg0 string) (*mgo_v2.Collection, state.SessionCloser) {
	ret := m.ctrl.Call(m, "GetRawCollection", arg0)
	ret0, _ := ret[0].(*mgo_v2.Collection)
	ret1, _ := ret[1].(state.SessionCloser)
	return ret0, ret1
}
875305
func (s *Session) GetAll() map[string]interface{} {
	items := make(map[string]interface{}, s.provider.db.Len(s.sid))
	s.mu.RLock()
	s.provider.db.Visit(s.sid, func(key string, value interface{}) {
		items[key] = value
	})
	s.mu.RUnlock()
	return items
}
310675
func (mongo *MongoDB) Count() int {
	c, _ := mongo.Collection.Count()
	return c
}
61029
func Init(session *mgo.Session) {
	if !flag.Parsed() {
		flag.Parse()
	}

	// alloc the collection managers
	vendorCM := storage.NewVendorCollectionManager(session)
	recordCM := storage.NewRecordCollectionManager(session)

	// alloc source manager
	sourceM, err := source.NewManager(*mockMode, *githubUsername)
	if err != nil {
		log.Fatal(err)
	}

	// alloc the worker
	worker := worker.NewWorker(sourceM, vendorCM, recordCM)

	// alloc timer
	timer, err := timer.NewTimer(time.Duration(*period), worker)
	if err != nil {
		log.Fatal(err)
	}

	timer.Run()

	// run rest service
	runRESTService()
}
275705
func (m *mongoStore) Get(r *http.Request, name string) (*gSessions.Session, error) {
	return gSessions.GetRegistry(r).Get(m, name)
}
763183
func (s *Store) RemoveCollection(name string) {
	for {
		orig := atomic.LoadPointer(&s.coll)
		coll := copyColl(*(*map[string]*Collection)(orig))
		cold := coll[name]
		delete(coll, name)
		if atomic.CompareAndSwapPointer(&s.coll, orig, unsafe.Pointer(&coll)) {
			cold.closeCollection()
			return
		}
	}
}
644948
func (s *SecretService) GetCollection(name string) dbus.BusObject {
	return s.Object(serviceName, dbus.ObjectPath(collectionBasePath+name))
}
276406
func (c CollectorF) Collect(key, val SophieWriter) error {
	if c == nil {
		return nil
	}
	return c(key, val)
}
74976
func (llss *llSnapshot) ChildCollectionNames() ([]string, error) {
	var childCollections = make([]string, len(llss.childSnapshots))
	idx := 0
	for name, _ := range llss.childSnapshots {
		childCollections[idx] = name
		idx++
	}
	return childCollections, nil
}
649558
func (s *MyMongo) Collection() pezdispenser.Persistence {
	sess := s.Session.Copy()
	return pezdispenser.NewMongoCollectionWrapper(sess.DB(s.mongoDBName).C(s.mongoCollName))
}
1366273
func (i *Item) List() ([]resources.Resource, error) {
	listers := resources.GetListers()
	return listers[i.Type](i.Region.Session)
}
1312178
func (r *Repo) Collection(ctx context.Context, f func(*mgo.Collection) error) error {
	sess := r.session.Copy()
	defer sess.Close()

	c := sess.DB(r.dbName(ctx)).C(r.collection)
	if err := f(c); err != nil {
		return eh.RepoError{
			Err:       err,
			Namespace: eh.NamespaceFromContext(ctx),
		}
	}

	return nil
}
348047
func (m *MockState) MongoSession() *mgo_v2.Session {
	ret := m.ctrl.Call(m, "MongoSession")
	ret0, _ := ret[0].(*mgo_v2.Session)
	return ret0
}
566779
func (s *Session) Get(ref types.ManagedObjectReference) mo.Reference {
	obj := s.Registry.Get(ref)
	if obj != nil {
		return obj
	}

	// Return a session "view" of certain singleton objects
	switch ref.Type {
	case "SessionManager":
		// Clone SessionManager so the PropertyCollector can properly report CurrentSession
		m := *Map.SessionManager()
		m.CurrentSession = &s.UserSession

		// TODO: we could maintain SessionList as part of the SessionManager singleton
		for _, session := range m.sessions {
			m.SessionList = append(m.SessionList, session.UserSession)
		}

		return &m
	case "PropertyCollector":
		if ref == Map.content().PropertyCollector {
			return s.Put(NewPropertyCollector(ref))
		}
	}

	return Map.Get(ref)
}
360488
func (t Type) Collection() string {
	defn := getDefn(t)
	switch {
	case strings.HasSuffix(defn.name, "access"):
		return defn.name
	default:
		return fmt.Sprintf("%ss", defn.name)
	}
}