Skip to main content

CircleCI Codacy Badge

MongoEngine Soft Delete

Make a document soft deletable.

Installation

Install mongoengine-softdelete through pip as usual:

pip install mongoengine-softdelete

Usage

Here is an example on how to use a soft deletable document:

from mongoengine_softdelete.document import SoftDeleteNoCacheDocument    

class IceCream(SoftDeleteNoCacheDocument):
    meta = {
        'collection': 'ice_cream',
        'soft_delete': {'deleted': True},
        'indexes': [ 'flavor' ],
        'strict': False
    }

    flavor = fields.StringField(required=True)
    color = fields.StringField(required=True)
    price = fields.FloatField(default=0)
    created_at = fields.DateTimeField()

    # Declare the field used to check if the record is soft deleted
    # this field must also be reported in the `meta['soft_delete']` dict
    deleted = fields.BooleanField(default=False)

# Save a new document
ice = IceCream(flavor="Vanilla", color="White").save()
assert not ice.is_soft_deleted

# Mark the document as soft deleted
ice.soft_delete()
assert len(IceCream.objects()) == 0
assert ice.is_soft_deleted

# Soft undelete the document
ice.soft_undelete()
assert len(IceCream.objects()) > 0
assert not ice.is_soft_deleted

Tests

The test suit requires that you run a local instance of MongoDB on the standard port and have pytest installed.
You can run tests with the pytest command or with make test.

Linting is done with mypy and pycodestyle with the make lint command.

Metadata

Release files for mongoengine-softdelete 0.0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mongoengine-softdelete 0.0.10
File Size Uploaded Provenance
mongoengine-softdelete-0.0.10.tar.gz 3.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mongoengine-softdelete 0.0.10
File Interpreter ABI Platform
mongoengine_softdelete-0.0.10-py3-none-any.whl Python 3 none any Details

Total release size: 7.8 kB

Release files / mongoengine-softdelete-0.0.10.tar.gz

Download URL mongoengine-softdelete-0.0.10.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
fecd609875ab6841b63eb67d3d898abcdd0bdfaba40cf57b836d233a358411c9
BLAKE2b-256 checksum
How to use checksums
7f9dad464c33d77ffda7522991575b8272e50be80d606ce720fc963a2966389e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.12 CPython/3.9.7 Linux/5.13.0-28-generic

Release files / mongoengine_softdelete-0.0.10-py3-none-any.whl

Download URL mongoengine_softdelete-0.0.10-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f5da5ac33199b24c504323e25e9d304ac0422ccb069a41cf0f556b7439a97904
BLAKE2b-256 checksum
How to use checksums
fa73bc22812843bdb158c2b17723852a6e2355eac708b57f95b1122d93c3835a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.12 CPython/3.9.7 Linux/5.13.0-28-generic

Security for mongoengine-softdelete 0.0.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page