happi.backends.mongo_db.MongoBackend

class happi.backends.mongo_db.MongoBackend(host: str, user: str, pw: str, db: str, collection: str, timeout: str | None = None, port: str | int = 27017, auth_source: str | None = None, **kwargs)

Abstraction for MongoDB backend.

Parameters:
  • host (str) – Hostname for MongoDB.

  • user (str) – Username for MongoDB instance.

  • pw (str) – Password for given username.

  • db (str) – Database name within the MongoDB instance.

  • collection (str) – MongoDB colleciton name

  • timeout (float, optional) – Time to wait for connection attempt.

  • port (str or int, optional) – Port of the MongoDB instance. Will be cast to int. Defaults to 27017 (mongo default) if no value is supplied

  • auth_source (str, optional) – AuthenticationSource for MongoDB instance, defaults to defaultauthdb if no value is supplied

__init__(host: str, user: str, pw: str, db: str, collection: str, timeout: str | None = None, port: str | int = 27017, auth_source: str | None = None, **kwargs) None

Methods

__init__(host, user, pw, db, collection[, ...])

clear_cache()

Request to clear any cached data.

delete(_id)

Delete an item instance from the database.

find(to_match)

Yield all instances that match the given search criteria.

find_range(key, *, start[, stop])

Find an instance or instances that matches the search criteria, such that start <= entry[key] < stop.

find_regex(to_match, *[, flags])

Yield all instances that match the given search criteria.

get_by_id(_id)

Get an item by ID if it exists, or return None.

save(_id, post[, insert])

Save information to the database.

Attributes

all_items

List of all item sub-dictionaries.