Create file viewer config schema
[arvados.git] / src / services / api / filter-builder.ts
index f83f574faf007fa948442cf32710c15c17cd9750..08746c81b9ee1d91736b4e9e09eb79b820bd916f 100644 (file)
@@ -31,6 +31,10 @@ export class FilterBuilder {
         return this.addCondition(field, "in", value, "", "", resourcePrefix);
     }
 
+    public addNotIn(field: string, value?: string | string[], resourcePrefix?: string) {
+        return this.addCondition(field, "not in", value, "", "", resourcePrefix);
+    }
+
     public addGt(field: string, value?: string, resourcePrefix?: string) {
         return this.addCondition(field, ">", value, "", "", resourcePrefix);
     }
@@ -47,6 +51,10 @@ export class FilterBuilder {
         return this.addCondition(field, "<=", value, "", "", resourcePrefix);
     }
 
+    public addExists(value?: string, resourcePrefix?: string) {
+        return this.addCondition("properties", "exists", value, "", "", resourcePrefix);
+    }
+
     public getFilters() {
         return this.filters;
     }
@@ -65,7 +73,9 @@ export class FilterBuilder {
                 ? 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;
     }