Skip to content

Instantly share code, notes, and snippets.

@voglster
Last active July 14, 2022 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save voglster/97ccf8cb7d2e7917522189939dfdc025 to your computer and use it in GitHub Desktop.
Save voglster/97ccf8cb7d2e7917522189939dfdc025 to your computer and use it in GitHub Desktop.
@classmethod
async def find_by_loss(
cls, name: str, insurance_type: str, org_id: PydanticObjectId | ObjectId
):
# This is ugly but required to handle case-insensitive queries as beanie doesn't seem to
return [
Commission.parse_obj(x)
for x in await Commission.get_motor_collection()
.find(
{
"name": name,
"insurance_type": insurance_type,
"organization_id": org_id,
}
)
.collation({"locale": "en", "strength": 2})
.to_list(None)
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment