class Marriage(BaseModel):
users = ArrayField(BigIntegerField)
chat_id = BigIntegerField()
class Meta:
indexes = (
(('users', "chat_id"), True),
)
I would like to make a unique index for both user values and chat_id for example:
there is already such a row in the database:
users=[1,2], chat_id=1
I would like to create the same but a different position in the user array.
users=[2,1], chat_id=1
I'd suggest consulting the Postgres folks as I'm not sure how you'd do that. I think the "best" solution is to store them flat:
Then to get all users for a marriage: