mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-13 14:44:43 -04:00
fix(notes-service): user query builder
For reasons, the typeorm 0.3 broke the find() method when using relations in the WHERE clause. This replaces the find method with a query builder. Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
27a93a2895
commit
d780d511cd
2 changed files with 38 additions and 14 deletions
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
import { forwardRef, Inject, Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Equal, Repository } from 'typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
import noteConfiguration, { NoteConfig } from '../config/note.config';
|
||||
import {
|
||||
|
@ -55,16 +55,10 @@ export class NotesService {
|
|||
* @return {Note[]} arary of notes owned by the user
|
||||
*/
|
||||
async getUserNotes(user: User): Promise<Note[]> {
|
||||
const notes = await this.noteRepository.find({
|
||||
where: { owner: Equal(user) },
|
||||
relations: [
|
||||
'owner',
|
||||
'userPermissions',
|
||||
'groupPermissions',
|
||||
'tags',
|
||||
'aliases',
|
||||
],
|
||||
});
|
||||
const notes = await this.noteRepository
|
||||
.createQueryBuilder('note')
|
||||
.where('note.owner = :user', { user: user.id })
|
||||
.getMany();
|
||||
if (notes === null) {
|
||||
return [];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue