adjusted filter in find form
This commit is contained in:
parent
2079f3873c
commit
5cddfb43de
@ -84,7 +84,7 @@ export class FormService {
|
|||||||
async find(formId: string): Promise<Form> {
|
async find(formId: string): Promise<Form> {
|
||||||
const form = await this.formModel
|
const form = await this.formModel
|
||||||
.findOne({ id: formId, deletedAt: null })
|
.findOne({ id: formId, deletedAt: null })
|
||||||
.select(LIST_PROJECTION)
|
.select(DETAIL_PROJECTION)
|
||||||
.exec();
|
.exec();
|
||||||
if (!form) throw new NotFoundException(`Form ${formId} not found`);
|
if (!form) throw new NotFoundException(`Form ${formId} not found`);
|
||||||
return form;
|
return form;
|
||||||
|
|||||||
@ -1,13 +1,12 @@
|
|||||||
import { QueryFormDto, SortOrder } from '../dto/query-form.dto';
|
import { QueryFormDto, SortOrder } from '../dto/query-form.dto';
|
||||||
|
|
||||||
export class FormQueryBuilder {
|
export class FormQueryBuilder {
|
||||||
|
// Build filter
|
||||||
static buildFilter(query: QueryFormDto): Record<string, unknown> {
|
static buildFilter(query: QueryFormDto): Record<string, unknown> {
|
||||||
const filter: Record<string, unknown> = {};
|
const filter: Record<string, unknown> = {};
|
||||||
|
|
||||||
if (query.search) {
|
if (query.search) {
|
||||||
filter.name = { $regex: query.search, $options: 'i' };
|
filter.name = { $regex: query.search, $options: 'i' };
|
||||||
}
|
}
|
||||||
|
|
||||||
return filter;
|
return filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user