Deprecated Get Methods
The following methods are deprecated and will be removed in a future version. Use
totalumClient.crud.query()instead.If you get an error like
query is not a function, update the SDK:npm install totalum-api-sdk@latest
getRecords (Deprecated)
Deprecated: Use
totalumClient.crud.query()instead. It supports the same filtering capabilities plus nested relations, counts, aggregations, and more.
Get items from a table with optional filtering, sorting, and pagination.
// OLD (deprecated):
const result = await totalumClient.crud.getRecords('client', {
filter: [
{ name: 'John' },
{ status: { regex: 'active', options: 'i' } },
{ age: { gte: 18 } },
{ country: { ne: 'Spain' } },
],
sort: { name: 1 }, // 1 = asc, -1 = desc
pagination: { limit: 50, page: 0 }
});
const items = result.data;
OR filter (old syntax)
const result = await totalumClient.crud.getRecords('client', {
filter: [
{ or: [{ status: 'active' }, { status: 'pending' }] }
]
});
AND + OR filter (old syntax)
const result = await totalumClient.crud.getRecords('client', {
filter: [
{ or: [{ status: 'active' }, { status: 'pending' }] },
{ country: 'Spain' }
]
});
Migration to query()
// NEW (recommended):
const result = await totalumClient.crud.query('client', {
_filter: {
name: 'John',
status: { regex: 'active', options: 'i' },
age: { gte: 18 },
country: { ne: 'Spain' },
},
_sort: { name: 'asc' },
_limit: 50
});
// OR filter:
const result2 = await totalumClient.crud.query('client', {
_filter: {
_or: [{ status: 'active' }, { status: 'pending' }]
}
});
// AND + OR filter:
const result3 = await totalumClient.crud.query('client', {
_filter: {
country: 'Spain',
_or: [{ status: 'active' }, { status: 'pending' }]
}
});
getNestedData (Deprecated)
Deprecated: Use
totalumClient.crud.query()instead. It supports the same nested data capabilities with a simpler syntax.
Get data with nested related tables in one query. Works for oneToMany, manyToOne, and manyToMany.
// OLD (deprecated):
const nestedQuery = {
client: {
order: {
product: {}
}
}
};
const result = await totalumClient.crud.getNestedData(nestedQuery);
const clients = result.data;
// clients[0].orders[0].products[0]...
With filters per level (old syntax)
const nestedQuery = {
client: {
tableFilter: {
filter: [{ name: 'John' }],
sort: { name: 1 },
pagination: { limit: 10, page: 0 }
},
order: {
product: {}
}
}
};
const result = await totalumClient.crud.getNestedData(nestedQuery);
Migration to query()
// NEW (recommended):
const result = await totalumClient.crud.query('client', {
_filter: { name: 'John' },
_sort: { name: 'asc' },
_limit: 10,
order: {
product: true
}
});
getManyToManyReferencesRecords (Deprecated)
Deprecated: Use
totalumClient.crud.query()instead. It handles manyToMany relations automatically.
Get manyToMany related records for a specific item.
// OLD (deprecated):
const result = await totalumClient.crud.getManyToManyReferencesRecords(
'client', // table name
clientId, // record id
'books', // manyToMany property name
{ // optional query
filter: [{ title: { regex: 'javascript', options: 'i' } }],
sort: { title: 1 },
pagination: { limit: 50, page: 0 }
}
);
const books = result.data;
Migration to query()
// NEW (recommended):
const result = await totalumClient.crud.query('client', {
_filter: { _id: clientId },
books: true
});
const books = result.data[0]?.books;
nestedFilter (Deprecated)
Deprecated: Use
totalumClient.crud.query()instead. It supports nested relation filtering with_filterand_hasat any depth.
Filter parent records based on conditions in child/nested tables.
// OLD (deprecated):
const nestedFilter = {
client: {
order: {
tableFilter: [{ state: 'completed' }],
product: {
tableFilter: [{ name: 'Cocacola' }]
}
}
}
};
const result = await totalumClient.filter.nestedFilter(nestedFilter, 'client', {
pagination: { limit: 50, page: 0 }
});
const clients = result.data;
Migration to query()
// NEW (recommended):
const result = await totalumClient.crud.query('client', {
_limit: 50,
order: {
_filter: { state: 'completed' },
_has: true,
product: {
_filter: { name: 'Cocacola' },
_has: true
}
}
});