Skip to main content

ORM to manage RethinkDB database objects

Project description

Rethink:Model

Build Status Quality Gate Status Documentation

Simple and easy to use ORM for RethinkDB. Use Python typing package and annotations to describe data representation.

RethinkModel aims to help you to describe your data as classes to be easilly created, updated and get from RethinkDB.

Rethink:Model make uses of typing support annotations - Python annotations describe the model fields. That’s easy, you only have to import the standard typing module, and use any of Optionnal, Type, List, Union… types.

It’s simple as a pie

from typing import Optional, List
from rethinkdb.model import Model

class Post(Model):
    author: User  # One to One relation to User
    content: str
    tags: Optional[List[str]] # use typing, tags can be None

class User(Model):
    login: str
    email: str

# save
user = User(login="John", email="me@foo.com").save()
post = Post(author=user, content="This is the post").save()

# get user
user = User.get(user.id)

# get Post
post = Post.get(post.id)
# post.author is an User, but in DB it's the ID

# get post from User ?
user = User.get(user.id).join(Project)
# user.projects is now filled

There are other methods like join(), get_all() and so on. Please check documentation.

The goals

  • Describe the models in the simplest possible way, but also in the most meaningful way
  • Make use of powerful typing package from Python > 3.7
  • Avoid type checking at runtime (What ?) but let your IDE punish you

Python is not a staticly typed langage. But Python developers want it (or not 😜) - So there are many Python tools that are designed to use typing package which is integrated with Python SDK: Pyright (use by PyLance), MyPy, PyType…

Your IDE can make type checking.

  • Vim can use coc-pyright
  • VsCode can use PyLance
  • PyCharm knows how to manage typing
  • etc…

So, let’s use typing ! Rethink:Model is designed to use the typing package.

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

rethinkmodel-0.1.1.tar.gz (11.0 kB view hashes)

Uploaded Source

Built Distribution

rethinkmodel-0.1.1-py3-none-any.whl (11.1 kB view hashes)

Uploaded Python 3

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