Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Expand
titleUpdated filter logic:
Code Block
const conditions = {
			and: [
				{hierarchy_id: hierarchyId},
				{organisation_id: organisationId},
			],
		};

		if (isDataSearchApplied) {
            searchQuery = helper.sanitizeStringCode(searchQuery);
            let queryString = `${searchQuery}%`;

			if (sortResult) {
				queryString = `%${queryString}`;
			}

			const orConditions = shouldIncludeNameInSearchFilterif (shouldSearchByName) {
				conditions.and.push({ name: ilike: queryString });
			} else if (shouldSearchByBothNameAndCode) {
				condition.and.push({
				?	or: [
						{ name: { ilike: queryString } },
						{ code: { ilike: queryString } }
					]
				:});

				[{ code:} else {
ilike: queryString } }];

				conditions.and.push({ code: orilike: orConditionsqueryString });
			}
        }
		
		const heirarchyData = await extendedModels.AddressNode.find({
			where: conditions,
			fields: { code: true, name: true, id: true }
		});
		

...