A simple programmatic builder for CommerceTools `where` [Query Predicates](https://docs.commercetools.com/api/predicates/query)
npm install commercetools-where-builderA simple programmatic builder for CommerceTools where Query Predicates
Performs stringification and quote escaping for string, boolean and numerical values
``typescript
import { Field, Equals, And } from "commercetools-where-builder";
Field(
"masterData",
"current",
"masterVariant",
And(
Equals("key", "my-variant-key"),
Field(
"attributes",
And(
Equals("name", "my-attribute-key"),
Equals("value", "my-attribute-value")
)
)
)
);
`
This snippet builds the following where query string
``
masterData(current(masterVariant((key = "my-variant-key") and (attributes((name = "my-attribute-key") and (value = "my-attribute-value"))))))
`typescript`
Field("bar", "baz", "foo"); // bar(baz(foo)))
`typescript`
And("bar", "baz"); // (bar) and (baz)
`typescript`
Or("bar", "baz"); // (bar) or (baz)
`typescript`
Compare("bar", "<=", 5); // bar <= 5
`typescript`
Equals("bar", 5); // bar = 5
`typescript`
NotEquals("bar", 5); // bar != 5
`typescript`
GreaterThan("bar", 5); // bar > 5
`typescript`
LessThan("bar", 5); // bar > 5
`typescript`
GreaterOrEqualThan("bar", 5); // bar >= 5
`typescript`
LessOrEqualThan("bar", 5); // bar <= 5
`typescript`
Contains("bar", "any", ["str", 123, true]); // bar contains any ("str", 123, true)
`typescript`
ContainsAll("bar", ["str", 123, true]); // bar contains all ("str", 123, true)
`typescript`
ContainsAny("bar", ["str", 123, true]); // bar contains any ("str", 123, true)
`typescript`
IsDefined("bar"); // bar is defined
`typescript`
IsNotDefined("bar"); // bar is defined
`typescript`
HasChanged("bar"); // bar has changed
`typescript`
HasNotChanged("bar"); // bar has not changed
`typescript``
WithinCircle("bar", 75.2345, 12.2345, 100); // bar within circle(75.2345, 12.2345, 100)