From 31ddca0f7d95b653a5f9ea13c2d167c34c8d4ff3 Mon Sep 17 00:00:00 2001 From: Carlin MacKenzie Date: Wed, 6 Nov 2024 16:42:22 +0100 Subject: [PATCH] domains: add find by id function --- invenio_accounts/datastore.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/invenio_accounts/datastore.py b/invenio_accounts/datastore.py index be4b799d..6db54f9f 100644 --- a/invenio_accounts/datastore.py +++ b/invenio_accounts/datastore.py @@ -115,6 +115,14 @@ def find_domain(self, domain): .one_or_none() ) + def find_domain_by_id(self, domain_id): + """Find a domain by id.""" + return ( + Domain.query.filter_by(id=domain_id) + .options(joinedload(Domain.category_name)) + .one_or_none() + ) + def create_domain(self, domain, **kwargs): """Create a new domain.""" return Domain.create(domain, **kwargs)