MongoDB Index migration tool
Project description
mongodex
Mongodex is a Python library to migrate your MongoDB database indexes.
Installation
pip install mongodex
How to use
To migrate your indexes to a MongoDB database, you need to create a dictionary that contains each collection index. The indexes must be a mongodex.Index
instance. For example:
from pymongo import ASCENDING, DESCENDING
import mongodex
collections = {
"<COLLECTION_NAME>": [
mongodex.Index({"<FIELD_NAME>": ASCENDING}, unique=True),
mongodex.Index({"<FIELD_NAME>": ASCENDING, "<FIELD_NAME>": ASCENDING}),
],
"<COLLECTION_NAME>": [
mongodex.Index({"<FIELD_NAME>": DESCENDING}, name="custom_index_name"),
]
}
Then you can migrate your indexes by calling the mongodex.migrate
function with your database URI.
mongodex.migrate("<DATABASE_URI>", collections)
Markdown docs generator
You can also create a markdown file with all your indexes using the same collection index dictionary mentioned in the previous topic. For example:
mongodex.md_generator(collections)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mongodex-0.0.1.tar.gz
(5.1 kB
view hashes)