Skip to content
Snippets Groups Projects
Commit 13e5b816 authored by Hugo SUBTIL's avatar Hugo SUBTIL
Browse files

fix: search issue

parent 857a2d54
No related branches found
No related tags found
No related merge requests found
...@@ -20,15 +20,15 @@ export class StructuresService { ...@@ -20,15 +20,15 @@ export class StructuresService {
} }
public async search(searchString: string, filters?: Array<any>): Promise<Structure[]> { public async search(searchString: string, filters?: Array<any>): Promise<Structure[]> {
let query: any;
if (searchString && filters) { if (searchString && filters) {
query = [...this.parseFilter(filters), { $text: { $search: searchString } }]; return this.structureModel
.find({ $and: [...this.parseFilter(filters), { $text: { $search: searchString } }] })
.exec();
} else if (filters) { } else if (filters) {
query = this.parseFilter(filters); return this.structureModel.find({ $or: this.parseFilter(filters) }).exec();
} else { } else {
query = [{ $text: { $search: searchString } }]; return this.structureModel.find({ $or: [{ $text: { $search: searchString } }] }).exec();
} }
return this.structureModel.find({ $or: query }).exec();
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment