Skip to content

Commit 651de9f

Browse files
[EdgeDB] Create Funding Account queries (#2974)
Co-authored-by: Carson Full <[email protected]>
1 parent 8fb2f87 commit 651de9f

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Injectable } from '@nestjs/common';
2+
import { PublicOf } from '~/common';
3+
import { RepoFor } from '~/core/edgedb';
4+
import { FundingAccount } from './dto';
5+
import { FundingAccountRepository } from './funding-account.repository';
6+
7+
@Injectable()
8+
export class FundingAccountEdgeDBRepository
9+
extends RepoFor(FundingAccount).withDefaults()
10+
implements PublicOf<FundingAccountRepository> {}

src/components/funding-account/funding-account.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { forwardRef, Module } from '@nestjs/common';
2+
import { splitDb } from '~/core';
23
import { AuthorizationModule } from '../authorization/authorization.module';
4+
import { FundingAccountEdgeDBRepository } from './funding-account.edgedb.repository';
35
import { FundingAccountLoader } from './funding-account.loader';
46
import { FundingAccountRepository } from './funding-account.repository';
57
import { FundingAccountResolver } from './funding-account.resolver';
@@ -10,7 +12,7 @@ import { FundingAccountService } from './funding-account.service';
1012
providers: [
1113
FundingAccountResolver,
1214
FundingAccountService,
13-
FundingAccountRepository,
15+
splitDb(FundingAccountRepository, FundingAccountEdgeDBRepository),
1416
FundingAccountLoader,
1517
],
1618
exports: [FundingAccountService],

src/components/funding-account/funding-account.repository.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Injectable } from '@nestjs/common';
22
import { node } from 'cypher-query-builder';
33
import { ChangesOf } from '~/core/database/changes';
4-
import { ID, Session } from '../../common';
4+
import { ID, Session, UnsecuredDto } from '../../common';
55
import { DtoRepository } from '../../core';
66
import {
77
createNode,
@@ -35,7 +35,7 @@ export class FundingAccountRepository extends DtoRepository(FundingAccount) {
3535
}
3636

3737
async update(
38-
existing: FundingAccount,
38+
existing: UnsecuredDto<FundingAccount>,
3939
changes: ChangesOf<FundingAccount, UpdateFundingAccount>,
4040
) {
4141
return await this.updateProperties(existing, changes);

src/components/funding-account/funding-account.service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,14 @@ export class FundingAccountService {
9494
input: UpdateFundingAccount,
9595
session: Session,
9696
): Promise<FundingAccount> {
97-
const fundingAccount = await this.readOne(input.id, session);
97+
const fundingAccount = await this.repo.readOne(input.id);
9898

9999
const changes = this.repo.getActualChanges(fundingAccount, input);
100100
this.privileges
101101
.for(session, FundingAccount, fundingAccount)
102102
.verifyChanges(changes);
103-
return await this.repo.update(fundingAccount, changes);
103+
const updated = await this.repo.update(fundingAccount, changes);
104+
return await this.secure(updated, session);
104105
}
105106

106107
async delete(id: ID, session: Session): Promise<void> {

0 commit comments

Comments
 (0)