Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/sdk/src/convertQuerytoClause.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,10 @@ function convertOperator(operator: string): torii.ComparisonOperator {
return "Lt";
case "$lte":
return "Lte";
case "$in":
return "In";
case "$nin":
return "NotIn";
default:
throw new Error(`Unsupported operator: ${operator}`);
}
Expand Down
16 changes: 16 additions & 0 deletions packages/sdk/src/queryBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,20 @@ class QueryEntity<T extends SchemaType> {
return this.addConstraint(field, value, Operator.lte);
}

public in(
field: FirstLevelKeys<T[keyof T & string][keyof T[keyof T & string]]>,
value: any
): QueryEntity<T> {
return this.addConstraint(field, value, Operator.in);
}

public notIn(
field: FirstLevelKeys<T[keyof T & string][keyof T[keyof T & string]]>,
value: any
): QueryEntity<T> {
return this.addConstraint(field, value, Operator.nin);
}

private addConstraint(
field: FirstLevelKeys<T[keyof T & string][keyof T[keyof T & string]]>,
value: any,
Expand Down Expand Up @@ -177,4 +191,6 @@ enum Operator {
gte = "$gte",
lt = "$lt",
lte = "$lte",
in = "$in",
nin = "$nin",
}
Loading