package Ġua . better dating . backend . data Ċ Ċ import Ġkotlinx . coroutines . reactive . await First Ċ import Ġorg . springframework . data . r 2 dbc . core .* Ċ import Ġorg . springframework . data . relational . core . query . Criteria Ċ import Ġorg . springframework . data . relational . core . query . Query Ċ import Ġjava . util .* Ċ Ċ class ĠUser Role Repository ( template Supplier : ĠLazy < R 2 dbc Entity Template >) Ġ{ ĊĠĠĠ Ġprivate Ġval Ġtemplate Ġby Ġtemplate Supplier ĊĊĠĠĠ Ġsuspend Ġfun Ġsave ( user Role : ĠUser Role ): ĠUser Role Ġ= Ġtemplate . insert < UserRole >(). using And Await ( user Role ) ĊĊĠĠĠ Ġsuspend Ġfun ĠfindAll ( profile Id : ĠUUID ): ĠList < UserRole > Ġ= ĠfindAll Mono ( profile Id ). await First () ĊĊĠĠĠ Ġfun ĠfindAll Mono ( profile Id : ĠUUID ) Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtemplate . select < UserRole >(). matching ( Query . query ( Criteria . where (" profile _ id "). ` is `( profile Id ))). all (). collect List () ĊĊĠĠĠ Ġsuspend Ġfun Ġdelete ( profile Id : ĠUUID ) Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtemplate . delete < UserRole >(). matching ( Query . query ( Criteria . where (" profile _ id "). ` is `( profile Id ))). all And Await () ĊĊĠĠĠ Ġsuspend Ġfun Ġfind Admin (): ĠUser Role ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtemplate . select < UserRole >(). matching ( Query . query ( Criteria . where (" role "). ` is `( Role . ROLE _ ADMIN ))). await First OrNull () Ċ }