Metadata-Version: 2.1
Name: mdb-fields-cleaner
Version: 0.0.16
Summary: 
Home-page: https://github.com/carlosvin/mdb-fields-cleaner
Author: Carlos Martin Sanchez
Author-email: carlos.martin-sanchez@mongodb.com
Requires-Python: >=3.9,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: pymongo (>=4.6.1,<5.0.0)
Project-URL: Repository, https://github.com/carlosvin/mdb-fields-cleaner
Description-Content-Type: text/markdown


# MongoDB fields Cleaner (WIP)

It simplifies the process of cleaning up old deprecated fields in a MongoDB database.

This will help you to easily remove obsolete/unused fields in your MongoDB collections so that you can save space in your DB.

## How to use it

It is as simple as [getting a pymongo.MongoClient](https://pymongo.readthedocs.io/en/stable/tutorial.html#making-a-connection-with-mongoclient) and pass it to the Cleaner constructor.

Once we have the Cleaner object instance, we just need to call the clean method with the collection name and the field names we want to keep ([unset](https://www.mongodb.com/docs/manual/reference/operator/update/unset/)), the fields not in this collection will be removed. This call will return an [UpdateResult object](https://pymongo.readthedocs.io/en/stable/api/pymongo/results.html#pymongo.results.UpdateResult).

```python
from mdb_fields_cleaner import Cleaner

client = MongoClient()
cleaner = Cleaner(client)

results: UpdateResult = cleaner.clean(collection.name, ["make", "model"])
print(f"{results.modified_count} modified documents")
```

## Development flow

1. Create a branch and a pull request.
1. Label the pull request with the correct semver label: patch, minor, major.
1. Get the PR approved and merged.

At this point the package should be published in Pypi.org registry.

