def set_collection(cls, collection_name): """Return a MongoDB collection for the passed name. :param collection_name: The name of collection to return. :returns: A MongoDB collection from the current database. """ return Database.db()[collection_name]
def ensure_indexing(): """Ensure that bamboo models are indexed.""" db = Database.db() calculations = db.calculations datasets = db.datasets observations = db.observations datasets.ensure_index([(DATASET_ID, ASCENDING)]) # The encoded dataset_id will be set to '0'. observations.ensure_index([("0", ASCENDING)]) observations.ensure_index([(Observation.ENCODING_DATASET_ID, ASCENDING)]) calculations.ensure_index([(DATASET_ID, ASCENDING)])
def ensure_indexing(): """Ensure that bamboo models are indexed.""" db = Database.db() calculations = db.calculations datasets = db.datasets observations = db.observations datasets.ensure_index([ ("BAMBOO_RESERVED_KEY_dataset_id", ASCENDING), ("BAMBOO_RESERVED_KEY_dataset_observation_id", ASCENDING)]) observations.ensure_index([ ("BAMBOO_RESERVED_KEY_dataset_observation_id", ASCENDING)]) calculations.ensure_index([("BAMBOO_RESERVED_KEY_dataset_id", ASCENDING)])
def ensure_indexing(): """Ensure that bamboo models are indexed.""" db = Database.db() # collections calculations = db.calculations datasets = db.datasets observations = db.observations # indices bamboo_index(datasets, DATASET_ID) bamboo_index(observations, ENCODED_DATASET_ID) bamboo_index(observations, Observation.ENCODING_DATASET_ID) bamboo_index(calculations, DATASET_ID)
def __drop_database(self): Database.client().drop_database(TEST_DATABASE_NAME)
def __create_database(self): Database.db(TEST_DATABASE_NAME)
def _drop_database(self): Database.connection().drop_database(TEST_DATABASE_NAME)