Skip to main content

MongoDB

In general the MongoDB query API works exactly as per pymongo, with the exception that:

  • inputs are wrapped in Document
  • additional support for vector-search is provided
  • queries are executed lazily

Inserts

from superduperdb.backends.mongodb import Collection

collection = Collection('my-collection-name')

db['my-collection'].insert_many([{'my-field': ..., ...}
for _ in range(20)
]).execute()

Updates

db['my-collection'].update_many(
{'<my>': '<filter>'},
{'$set': ...},
).execute()

Selects

db['my-collection'].find({}, {'_id': 1}).limit(10).execute()

Vector-searches may be integrated with .find.

db['my-collection'].like({'img': <my_image>}, vector_index='my-index-name').find({}, {'img': 1}).execute()

Read more about vector-search here.

Deletes

db['my-collection'].delete_many({}).execute()