Skip to main content

Basic usage & filtering

The most common way to use fetchOneRecord is by providing a table and a where filter to uniquely identify the record.

Simple filter

This example shows how to fetch a single user record by their unique user_id

TypeScript
const user = await db.fetchOneRecord({
table: "users",
where: { user_id: 12345 },
});

console.log(user);

Multiple conditions

You can combine multiple conditions to narrow your search.

TypeScript
const user = await manta.fetchOneRecord({
table: 'users',
where: {
user_id: 'user-1',
email: 'alice@example.com'
}
});

Available filter operators

fetchOneRecord supports the same user-friendly operators as fetchAllRecords.

OperatorDescriptionExample
equalsExact match{ field: 'value' } or { field: { equals: 'value' } }
notEqualsNot equal{ field: { notEquals: 'value' } }
greaterThanGreater than{ field: { greaterThan: 100 } }
lessThanLess than{ field: { lessThan: 100 } }
atLeastGreater than or equal{ field: { atLeast: 100 } }
atMostLess than or equal{ field: { atMost: 100 } }
inIn array{ field: { in: ['a', 'b', 'c'] } }
notInNot in array{ field: { notIn: ['a', 'b', 'c'] } }
TypeScript
// using filter operators
const order = await manta.fetchOneRecord({
table: "orders",
where: {
amount: { greaterThan: 100 },
status: "completed",
},
});