export class SearchFormService {
	applySearchConditionsToQueryObject(queryObject: any, searchModel: any) {
		if (searchModel) {
		  Object.entries(searchModel).forEach(([key, value]) => {
			var clause: string = "contains";	//Default
			if (value !== null && value !== undefined) {
			  switch(typeof value) { 
				case 'string': {
				  // Don't search with an empty string criteria
				  if (value.trim() === "") return;
				  clause = "contains";
				  break;
				}
				case 'boolean': {
				  clause = "equals";
				  break;
				}
				case 'number': {
				  clause = "equals";
				  break;
				}
			  }
			  
			  queryObject[key + "." + clause] = value;
			}
		  });
		}
	}
}