Search.../

queryDiscountRules( )

Developer Preview

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(),in(),startsWith(),exists(),ascending(),descending()
revisioneq(),ne(),in(),gt(),ge(),lt(),le(),exists(),ascending(),descending()
_createdDateeq(),ne(),in(),gt(),ge(),lt(),le(),exists(),ascending(),descending()
_updatedDateeq(),ne(),in(),gt(),ge(),lt(),le(),exists(),ascending(),descending()
activeeq(),ne(),in(),exists(),ascending(),descending()
nameeq(),ne(),in(),startsWith(),exists(),ascending(),descending()
activeTimeInfo.starteq(),ne(),in(),gt(),ge(),lt(),le(),exists(),ascending(),descending()
activeTimeInfo.endeq(),ne(),in(),gt(),ge(),lt(),le(),exists(),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