nestjs-query
nestjs-query copied to clipboard
RelationQueryService query should be async
Hello guys,
One thing I think it would be useful is that the RelationQueryService should support async for virtual relations. At the moment you can't use async response for the query method.
e.g:
@QueryService(TodoItemReferenceDTO)
export class TodoItemService extends RelationQueryService<TodoItemReferenceDTO> {
constructor(@InjectQueryService(SubTaskEntity) readonly subTaskService: QueryService<SubTaskEntity>) {
super({
// the name of the relation
subTasks: {
service: subTaskService,
// a query factory that will take in the reference to create a query.
async query: (todoItemReferenceDTO) => (
// Do some database request or whatever
return { filter: { todoItemId: { eq: todoItemReferenceDTO.id } } }
),
},
});
}
}
Good idea!
Just out of interest: what are you planning to do there that needs async?
I was thinking to use this in a virtual relation but I need to touch the database first.