bartongroup / slivka

http://bartongroup.github.io/slivka/
Apache License 2.0
7 stars 3 forks source link

Use base64 encoded object id to identify jobs. #106

Closed warownia1 closed 3 years ago

warownia1 commented 3 years ago

Currently, jobs are referred to by a generated uuid. The same role can be fulfilled by an object id adding the benefits of database indexing. A b64id property can be added to the MongoDocument that will return a base64 encoded object id.

Additionally, MongoDocument#find_one can be extended to accept an id parameter and, based on it's length, will perform a search by id. i.e.

def find_one(database, **query):
    if 'id' in query:
        id = query.pop('id')
        # 16 chars indicate b64 encoded 12 bytes
        id = b64decode(id) if len(id) == 16 else id
        query['_id'] = ObjectId(id)
    ...