Search.../

queryDiscountRules( )

Creates a query to retrieve a list of discount rules.

Description

The queryDiscountRules() function builds a query to retrieve a list of up to 100 discount rules, and returns a DiscountRulesQueryBuilder object.

The returned object contains the query definition which is typically used to run the query using the find() function.

You can refine the query by chaining DiscountRulesQueryBuilder functions onto the query. DiscountRulesQueryBuilder functions enable you to sort, filter, and control the results queryDiscountRules() returns.

By default, queryDiscountRules() sorts results by ascending("_id") by default. This can be overridden.

To learn how to query posts, refer to the table below.

The following DiscountRulesQueryBuilder functions are supported for the queryDiscountRules() function. For a full description of the discount rule object, see the object returned for the items property in DiscountRulesQueryResult.

PROPERTYSUPPORTED FILTERS & SORTING
_ideq(),ne(),exists(),in(),hasSome(),startsWith(),ascending(),descending()
revisioneq(),ne(),exists(),in(),hasSome(),lt(),le(),gt(),ge(),ascending(),descending()
_createdDateeq(),ne(),exists(),in(),hasSome(),lt(),le(),gt(),ge(),ascending(),descending()
_updatedDateeq(),ne(),exists(),in(),hasSome(),lt(),le(),gt(),ge(),ascending(),descending()
activeeq(),ne(),exists(),in(),hasSome(),ascending(),descending()
nameeq(),ne(),exists(),in(),hasSome(),startsWith(),ascending(),descending()
activeTimeInfo.starteq(),ne(),exists(),in(),hasSome(),lt(),le(),gt(),ge(),ascending(),descending()
activeTimeInfo.endeq(),ne(),exists(),in(),hasSome(),lt(),le(),gt(),ge(),ascending(),descending()
Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function queryDiscountRules(): DiscountRulesQueryBuilder

queryDiscountRules Parameters

This function does not take any parameters.

Returns

Was this helpful?

queryDiscountRules example

Copy Code
1import { discountRules } from 'wix-ecom-backend';
2
3 async function queryDiscountRules() {
4 const { items } = discountRules.queryDiscountRules().find();
5 }
6