Skip to main content

Filtering

The where parameter allows you to retrieve a subset of records by specifying filter conditions. You can use simple equality checks or a variety of powerful operators to build your query.

Available filter operators

You can use the following operators to build complex and precise filters.

OperatorDescriptionExample
equalsFinds an exact match.{ field: 'value' }
notEqualsFinds records where the field is not equal to a value.{ field: { notEquals: 'value' } }
greaterThanFinds records with a value greater than the specified number.{ field: { greaterThan: 100 } }
lessThanFinds records with a value less than the specified number.{ field: { lessThan: 100 } }
atLeastFinds records with a value greater than or equal to a number.{ field: { atLeast: 100 } }
atMostFinds records with a value less than or equal to a number.{ field: { atMost: 100 } }
inFinds records where the field's value is in the given array.{ field: { in: ['a', 'b', 'c'] } }
notInFinds records where the field's value is not in the given array.{ field: { notIn: ['a', 'b', 'c'] } }

Simple filters

Example 1: This example retrieves all active users from the users table.

TypeScript
// Simple filter to get active users
const users = await manta.fetchAllRecords({
table: 'users',
where: { status: 'active' },
page: 1,
list: 10
});

Example 2: This example retrieves all completed orders with an amount greater than $100.

TypeScript
// Multiple conditions to find completed orders over $100
const orders = await manta.fetchAllRecords({
table: 'orders',
where: {
status: 'completed',
amount: { greaterThan: 100 }
},
page: 1,
list: 10
});

Complex filtering

Example 1: This example retrieves all orders with an amount between $10 and $1000, excluding those with a status of "cancelled".

TypeScript
// Filter for a range of values
const orders = await manta.fetchAllRecords({
table: "orders",
where: {
amount: { greaterThan: 10, atMost: 1000 },
status: { notEquals: "cancelled" },
},
page: 1,
list: 10,
});

Example 2: This example retrieves all users whose role is either "admin", "manager", or "editor", but excludes those in the "HR" or "Finance" departments.

TypeScript
// Filter by values contained in an array
const users = await manta.fetchAllRecords({
table: "users",
where: {
role: { in: ["admin", "manager", "editor"] },
department: { notIn: ["HR", "Finance"] },
},
page: 1,
list: 10,
});