Git Product home page Git Product logo

repository-orm's Introduction

Repository ORM

Actions Status Actions Status Coverage Status

Library to ease the implementation of the repository pattern.

One of the disadvantages of using the repository pattern is that developers need to add and maintain a new abstraction to manage how to persist their models in the storage. repository-orm aims to mitigate this inconvenient by:

  • Supplying classes that already have the common operations for different storage solutions.
  • Supplying test classes and fixtures so extending the provided repositories is easy.

Help

See documentation for more details.

Installing

pip install repository-orm

Contributing

For guidance on setting up a development environment, and how to make a contribution to repository-orm, see Contributing to repository-orm.

Donations

Donate using
Liberapay or ko-fi

If you are using some of my open-source tools, have enjoyed them, and want to say "thanks", this is a very strong way to do it.

If your product/company depends on these tools, you can sponsor me to ensure I keep happily maintaining them.

If these tools are helping you save money, time, effort, or frustrations; or they are helping you make money, be more productive, efficient, secure, enjoy a bit more your work, or get your product ready faster, this is a great way to show your appreciation. Thanks for that!

And by sponsoring me, you are helping make these tools, that already help you, sustainable and healthy.

License

GPLv3

repository-orm's People

Contributors

actions-user avatar lyz-code avatar zznty avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

repository-orm's Issues

PypikaRepository can't be extended to support other db types

Description

Currently we have PypikaRepository supporting just SQLlite with promised support for other types (MySQL, PostgreSQL),
but to add this support we will need to create dedicated repository classes such as PostgreSqlRepository, because combining everything into one class will result in tons of conditions and unnecessary complication of code.

Possible Solutions

  • Rename current version of PypikaRepository to SQLliteRepository, but can result in code duplication for generic pypika operations.
  • Extract generic methods for pypika into PypikaRepository and create SQLliteRepository with SQLlite-related code

Support migrations for the TinyDB repository

Description

Even though TinyDB is meant to be schemaless, we could have a tool like yoyo for sql to do changes in the existent objects to conform to the new schema.

Possible Solution

Create a TinyDB extension that can read a list of files from a migrations directory and execute the steps defined there. Each file will have a hash, and the latest applied can be saved in the _tinydb_migrations table in the database.

I'd copy how yoyo has already solved the issue.

Add support for MongoDB

Description

Create a repository with a mongoDB backend

Possible Solution

Maybe we could use OMDantic

Additional context

Related Issue

mypy type error

First of all thanks for the very useful library. Here's my question:
I use an "Entity" class like this:

class MyClass(Entity):
    foo: str
    ...

I want to add a list of MyClass objects like this:

repo.add(my_objs)

my_objs has the type List[MyClass]
This works perfectly but the problem is that surprisingly I get a mypy error:

Value of type variable "EntityOrEntities" of "add" of "Repository" cannot be "List[MyClass]"

Am I doing something wrong? How can I resolve this?

Thank you very much

Support mappers

Description

It would be nice if the repositories could load a schema to understand the relationship between entities.

In this schema we could define the following relationships:

  • One to one
  • One to many
  • Many to many

In a way that when we .get an object we get the option to load the mappers, and if they are, the repo will get the required objects and load them in the specified attribute.

Possible Solution

At repo initialization, a schema attribute is set with the desired relationships.

Then we will need to decide how it affects the different base methods.

Additional context

Related Issue

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.