UNPKG

@convex-dev/geospatial

Version:
52 lines 1.46 kB
export class FilterBuilderImpl { filterConditions = []; interval; inDefined = false; eq(field, value) { this.filterConditions.push({ filterKey: field, filterValue: value, occur: "must", }); return this; } in(field, values) { if (this.inDefined) { throw new Error("Invalid query: Can't have multiple `in` clauses."); } this.inDefined = true; for (const value of values) { this.filterConditions.push({ filterKey: field, filterValue: value, occur: "should", }); } return this; } gte(field, value) { if (!this.interval) { this.interval = { startInclusive: value }; } else if (!this.interval.startInclusive) { this.interval.startInclusive = value; } else { this.interval.startInclusive = Math.max(this.interval.startInclusive, value); } return this; } lt(field, value) { if (!this.interval) { this.interval = { endExclusive: value }; } else if (!this.interval.endExclusive) { this.interval.endExclusive = value; } else { this.interval.endExclusive = Math.min(this.interval.endExclusive, value); } return this; } } //# sourceMappingURL=query.js.map