encode / orm

An async ORM. 🗃
https://www.encode.io/orm
BSD 3-Clause "New" or "Revised" License
1.78k stars 98 forks source link

How to support 'unique_together' #153

Open LuoLuo0101 opened 2 years ago

LuoLuo0101 commented 2 years ago

class RoleMenu(orm.Model): tablename = "role_menu" registry = registry_main

fields = {
    "id": orm.BigInteger(primary_key=True),
    "role_id": orm.BigInteger(index=True),
    "menu_id": orm.BigInteger(index=True),
    "is_active": orm.Boolean(default=False),
    "is_new": orm.Boolean(default=True),
}
# unique_together = (("role_id", "menu_id"),)
SepehrBazyar commented 2 years ago

Hi I needed this feature in this project, therefore in this PR I tried to implement it. I would really appreciate it if you take a look. Thank you!