Metadata-Version: 2.4
Name: pymangodb
Version: 0.1.1
Summary: A lightweight, dependency-free document database for Python
Home-page: https://github.com/orfeous/mangodb
Author: Gabor Racz
Author-email: Gabor Racz <orfeous@olab.app>
Project-URL: Homepage, https://github.com/orfeous/mangodb
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Operating System :: OS Independent
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: author
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-python

# MangoDB

A lightweight, thread-safe document database that stores data in a single JSON file.

![PyPI - Status](https://img.shields.io/pypi/status/pymangodb) ![PyPI - Format](https://img.shields.io/pypi/format/pymango)



## Features

- Thread-safe operations with read-write locking
- Support for concurrent reads
- Batch operations for better performance
- Automatic version control with backup files
- Custom Python type serialization
- Platform independent (Linux, Windows, MacOS)
- No external dependencies

## Installation

```bash
pip install pymangodb
```

## Quick Start

```python
from mangodb import MangoDB

# Initialize database
db = MangoDB("data.json")

# Insert documents
doc_id = db.insert("users", {"name": "Alice", "age": 25})

# Batch insert
doc_ids = db.batch_insert("users", [
    {"name": "Bob", "age": 30},
    {"name": "Charlie", "age": 35}
])

# Find documents
results = db.find("users", {"age": {"$gt": 30}})

# Update documents
db.update("users", {"name": "Alice"}, {"age": 26})

# Batch update
db.batch_update("users", [
    {"query": {"name": "Bob"}, "update": {"age": 31}},
    {"query": {"name": "Charlie"}, "update": {"age": 36}}
])

# Delete documents
db.delete("users", {"name": "Charlie"})
```

## Thread Safety

All operations are thread-safe. The database uses a two-tier locking mechanism:
- Read operations can run concurrently
- Write operations are serialized

## Version Control

Enable automatic backups before modifications:

```python
db.version_control(True)  # Creates backup files before changes
```

## Custom Types

Register your custom classes for serialization:

```python
class Person:
    def __init__(self, name, age):
        self.name = name
        self.age is age

db.register_type(Person)
db.insert("people", Person("Alice", 25))
```

See [API.md](API.md) for detailed documentation.

## Notice
The codebase may contain AI slop.

## License

MIT License
