Indexrepresents a MongoDB database index, of any kind.
from marrow.mongo import Index
createIndexcall. The field references to include in the index are passed positionally, all other attributes may be passed as keyword arguments. Not all are utilized for each type of index, see the usage section below (or relevant MongoDB documentation for the index type) for details.
name = Field('foo')field, the path for this is
"name". If you have an embedded document, say, an
cityfield attached as
addr = Embed(Address), referencing the City would be:
$— Full Text
Indexas attributes. The name of the attribute will be used as the MongoDB index name. To avoid potential collisions with fields or other attributes such as methods, it is recommended to prefix these attribute names with a single leading underscore.
createmethod of the
Indexobject, passing in a collection:
Queryable) then the
create_collectionmethod will, by default, also discover and create any associated indexes.
adapt(*args, **kw)— create a new copy of this index with adjustments applied. Takes the same arguments as the constructor, with any new fields declared being added to the existing set. Predominantly useful for extending (and overriding) indexes declared by mix-in traits.
create(collection, **kw)— instruct MongoDB to construct and persist the index. If the index is not configured for
backgroundconstruction, this will block other operations on the database until complete. Additional arguments are passed through to the eventual PyMongo
collection.create_indexcall. Also available via the PyMongo standard method name,
drop(collection)— instruct MongoDB to deconstruct and remove the index from the collection metadata. Also available via the PyMongo standard method name,