Skip to main content

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


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 details)

Uploaded Source

Built Distribution

mongodex-0.0.1-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file mongodex-0.0.1.tar.gz.

File metadata

  • Download URL: mongodex-0.0.1.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.2

File hashes

Hashes for mongodex-0.0.1.tar.gz
Algorithm Hash digest
SHA256 e381aa3b9333594c2d8915fd290f945ec574aa8668d1f96932eb39f3cccd576a
MD5 55bcad755de1937d1b78a8cee5ec06bf
BLAKE2b-256 454e8ee05795742b9ec6b84c69313b6d467234b0c74e16a99a6c6a51e35281cc

See more details on using hashes here.

File details

Details for the file mongodex-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: mongodex-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.2

File hashes

Hashes for mongodex-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 25e6877f6973c8469c5ba3327baae539acca48ba42a01b12da45ca3572577319
MD5 f8b8567c24d7d3ea1e4fcc6c66868311
BLAKE2b-256 fccec29ab81ea4c945efbedfcaed795d782a6f591a81836e4423954ef0030af8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page