return this.addCondition(field, "<=", value, "", "", resourcePrefix);
}
+ public addExists(value?: string, resourcePrefix?: string) {
+ return this.addCondition("properties", "exists", value, "", "", resourcePrefix);
+ }
+
public getFilters() {
return this.filters;
}
? resourcePrefix + "."
: "";
- this.filters += `${this.filters ? "," : ""}["${resPrefix}${_.snakeCase(field)}","${cond}",${value}]`;
+ const fld = field.indexOf('properties.') < 0 ? _.snakeCase(field) : field;
+
+ this.filters += `${this.filters ? "," : ""}["${resPrefix}${fld}","${cond}",${value}]`;
}
return this;
}
const getFirstProp = (sq: ParseSearchQuery, name: string) => sq.properties[name] && sq.properties[name][0];
const getPropValue = (sq: ParseSearchQuery, name: string, value: string) => sq.properties[name] && sq.properties[name].find((v: string) => v === value);
-const getProperties = (sq: ParseSearchQuery) => {
+const getProperties = (sq: ParseSearchQuery): PropertyValues[] => {
if (sq.properties.has) {
return sq.properties.has.map((value: string) => {
const v = value.split(':');
if (dateTo) {
filter.addLte('modified_at', buildDateFilter(dateTo));
}
- }
- // TODO: has props
+ const props = getProperties(sq);
+ props.forEach(p => {
+ // filter.addILike(`properties.${p.key}`, p.value);
+ filter.addExists(p.key);
+ });
+ }
return filter
.addEqual('groupClass', GroupClass.PROJECT, GroupContentsResourcePrefix.PROJECT)