-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
aggregationId
for aggregations (#465)
* ft: add aggregation id migration script * refactor: update aggregation pg adapter methods * ft: get aggregation using id pg adapter method * refactor: aggregation model class to use updated pg adapter methods/params * chore: aggregation db adapter method documentation * chore: todo comments * refactor: simply step 2 of add aggregation id migration script * ft: add aggregationId to `LinkedAggregation` in GQL API * fix: remove redundant part of `getAggregation` sql qeury * fix: add `source_account_id` to primary key of aggregations table
- Loading branch information
1 parent
f94f332
commit e6f3ba8
Showing
21 changed files
with
300 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
packages/hash/api/src/db/postgres/aggregation/getAggregation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { sql } from "slonik"; | ||
import { DbAggregation, DbClient } from "../../adapter"; | ||
|
||
import { Connection } from "../types"; | ||
import { | ||
DbAggregationRow, | ||
aggregationsColumnNamesSQL, | ||
mapRowToDbAggregation, | ||
} from "./util"; | ||
|
||
export const getAggregation = async ( | ||
conn: Connection, | ||
params: Parameters<DbClient["getAggregation"]>[0], | ||
): Promise<DbAggregation | null> => { | ||
const row = await conn.maybeOne<DbAggregationRow>(sql` | ||
select ${aggregationsColumnNamesSQL} | ||
from aggregations | ||
where aggregation_id = ${params.aggregationId} | ||
`); | ||
|
||
return row ? mapRowToDbAggregation(row) : null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.