Chaining

Last updated last month

This feature is currently in BETA and you should expect it to change.

You can chain filters to a query by using a colon (:) to separate your filters.

For example, to find all draft products with the slug 'new-slug' which have a stock greater than 2 and sorted by created_at, you can make the following request:

cURL
JavaScript SDK
Swift SDK
curl -X GET https://api.moltin.com/v2/products?filter=eq(status,draft):eq(commodity_type,physical) \
-H "Authorization: Bearer XXXX"
const MoltinGateway = require('@moltin/sdk').gateway
const Moltin = MoltinGateway({
client_id: 'X'
})
Moltin.Products.Filter({
eq: {
status: 'draft',
slug: 'new-slug'
},
gt: {
stock: 2
}
}).All()
.Sort('created_at')
.then(products => {
// Do something
})
let moltin = Moltin(withClientID: "<your client ID>")
moltin.product
.filter(operator: .eq, key: "commodity_type", value: "physical")
.sort("created_at")
.all {
// Do something
}