Skip to main content

Experimental Object-Document-Mapper using pydantic to store objects on Aleph.im

Project description

AARS - Aleph Active Record SDK

AARS is a powerful and flexible Python library built on top of the Aleph decentralized storage network, designed to help you build better backends for your decentralized applications. It provides an easy-to-use interface for managing and querying your data, with a focus on performance and versatility.

Features

  • Asynchronous, high-performance data storage and retrieval
  • Customizable schema with support for different data types
  • Indexing for efficient querying
  • Revision history tracking for records
  • Support for forgetting data (GDPR compliant)
  • Built-in pagination for large result sets

Installation

Install AARS using pip:

pip install aars

Getting Started

To get started with AARS, you will need to define your data schema by creating classes that inherit from Record. These classes represent the objects you want to store and query on the Aleph network.

Here's an example of how you can implement a simple social media platform, that we'll call "Chirper":

from src.aars import Record

class User(Record):
    username: str
    bio: str

class Chirp(Record):
    author: User
    content: str
    likes: int
    timestamp: int

In this example, we have a User class representing a user of Chirper, and a Chirp class representing a user's message. Now, let's create some indices to make querying our data more efficient:

from src.aars import Index

Index(User, 'username')
Index(Chirp, 'author')
Index(Chirp, 'timestamp')

With the schema defined and indices created, we only need to initialize an AARS session:

from src.aars import AARS

AARS()

It is enough to call the constructor once, and it will automatically initialize the session with the default settings.

We can now perform various operations, such as creating new records, querying records, and updating records:

import time

# Create a new user
new_user = await User(username='chirpy_user', display_name='Chirpy User', bio='I love chirping!').save()

# Create a new chirp
new_chirp = await Chirp(author=new_user, content='Hello, Chirper!', likes=0, timestamp=int(time.time())).save()

# Query chirps by author
chirps_by_author = await Chirp.filter(author=new_user).all()

# Update a chirp
new_chirp.likes += 1
updated_chirp = await new_chirp.save()

Documentation

For detailed documentation, including advanced features such as revision history, forgetting data, and pagination, refer to the docs folder in the repository or visit the official documentation website.

Building the Docs

To build the documentation, you will need to install the dependencies listed in the requirements.txt and docs-requirements.txt. Then, run the following command:

mkdocs build

You can serve the documentation locally by running the following command:

mkdocs serve

Contributing

Contributions to AARS are welcome! If you have found a bug, want to suggest an improvement, or have a question, feel free to open an issue on the GitHub repository.

License

AARS is released under the MIT License.

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

aars-0.7.4.tar.gz (22.9 kB view details)

Uploaded Source

Built Distribution

aars-0.7.4-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file aars-0.7.4.tar.gz.

File metadata

  • Download URL: aars-0.7.4.tar.gz
  • Upload date:
  • Size: 22.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.16

File hashes

Hashes for aars-0.7.4.tar.gz
Algorithm Hash digest
SHA256 95ad4d132479f41ce6a20764328b79a64bd2bff4e545e5c5517e5e449a3b25de
MD5 f2928a6595af02047a86b529be1a6b45
BLAKE2b-256 6db8840466463ce41bd57cd881dfc2178a8a4a1a0af9ea10d58eb71358e083b5

See more details on using hashes here.

File details

Details for the file aars-0.7.4-py3-none-any.whl.

File metadata

  • Download URL: aars-0.7.4-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.16

File hashes

Hashes for aars-0.7.4-py3-none-any.whl
Algorithm Hash digest
SHA256 31193ae87851df7dff67f0224aafcbeb147663afb166722ed3c766bb0d1f07f0
MD5 db9bd60135c4e500abdc60f728ee9c48
BLAKE2b-256 99d4cc2f01ec281840a33d410da8da068da0b170223baa02929f624db8592642

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