graasp / graasp/graasp-api

[Field Report] Inneficiency of typeorm queries

Open
#1,170 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
7
Forks
5
PR merge metrics
No merged PRs in 30d

Description

```ts
/**
* this function is a test to try to make the queries more efficient while still
* getting the return values in one go.
* but this is really type unsafe, since we have to use the raw sql output provided by typeorm
* the normal `update` method from typeorm results in 3 Sql queries (because it needs to fetch the relation beforehand) and does not even allow us to get the resulting data.
*
* Not using the ORM means that the datetime columns are not updated from snake_case to camelCase, so they are not present at validation
*/
const {
raw: [profile],
} = await this.repository
.createQueryBuilder()
.update(MemberProfile)
.set(data)
.where('member.id = :memberId', { memberId })
.returning('*')
.execute();

```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.