-
Notifications
You must be signed in to change notification settings - Fork 2
3) Database Queries
huntsman-drp
uses a mongoDB
database to store metadata. mongoDB
databases can store nested items which are similar to python dictionaries. It is recommended to familiarise yourself with the basics mongoDB
before proceeding.
The relevant mongoDB
terminology is as follows:
-
Document: A single item in the database. This is in some sense equivalent to a "row" in a standard database table, but can be a nested object.
-
Collection: A collection is similar to a table in a standard database, but contains a set of documents. Documents in a collection do not have to share the same data structure.
In huntsman-drp
, there are several collections:
-
ExposureCollection
: This is used to store metadata for all raw exposures. Each document pertains to a single exposure. -
MasterCalibCollection
: This stores metadata for archived master calibs. Each document pertains to a master calib.
These collections should be accessed via the huntsman-drp
python API, e.g.:
from huntsman.drp.collection import ExposureCollection
ec = ExposureCollection()
All huntsman-drp
collection objects support the basic mongoDB
operations, e.g. find
, insert
, update
and delete
. However they facilitate simplified querying, e.g.:
docs = ec.find({"dataType": "science"}, date_start="2021-05-14")
The first argument to the find
operation is the "document filter". This is a python dictionary that is used to match with other documents in the collection. Only matching documents are returned.
In the above code snippet, docs
is a list of huntsman.drp.document.ExposureDocument
, which behave very similarly to python dictionaries.
Conditional operators etc. TBD.