Skip to content

Commit 58ccba5

Browse files
authored
Merge pull request #364 from dojoengine/fix/in-operator
fix: support in operator
2 parents 33821e5 + b9cb6be commit 58ccba5

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

packages/sdk/src/convertQuerytoClause.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,10 @@ function convertOperator(operator: string): torii.ComparisonOperator {
313313
return "Lt";
314314
case "$lte":
315315
return "Lte";
316+
case "$in":
317+
return "In";
318+
case "$nin":
319+
return "NotIn";
316320
default:
317321
throw new Error(`Unsupported operator: ${operator}`);
318322
}

packages/sdk/src/queryBuilder.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,20 @@ class QueryEntity<T extends SchemaType> {
140140
return this.addConstraint(field, value, Operator.lte);
141141
}
142142

143+
public in(
144+
field: FirstLevelKeys<T[keyof T & string][keyof T[keyof T & string]]>,
145+
value: any
146+
): QueryEntity<T> {
147+
return this.addConstraint(field, value, Operator.in);
148+
}
149+
150+
public notIn(
151+
field: FirstLevelKeys<T[keyof T & string][keyof T[keyof T & string]]>,
152+
value: any
153+
): QueryEntity<T> {
154+
return this.addConstraint(field, value, Operator.nin);
155+
}
156+
143157
private addConstraint(
144158
field: FirstLevelKeys<T[keyof T & string][keyof T[keyof T & string]]>,
145159
value: any,
@@ -177,4 +191,6 @@ enum Operator {
177191
gte = "$gte",
178192
lt = "$lt",
179193
lte = "$lte",
194+
in = "$in",
195+
nin = "$nin",
180196
}

0 commit comments

Comments
 (0)