X
Xata6mo ago
Oreki

quick question, how can i get all

quick question, how can i get all records who do not have a linked entry, for example
const entries = await variables.database.db.markets.filter('card.id', null).getAll();
const entries = await variables.database.db.markets.filter('card.id', null).getAll();
would something like this work?
3 Replies
kostas
kostas6mo ago
Hi, use the exists filter (https://xata.io/docs/sdk/filtering#control-operators) to select links that have an id set (so they're not null):
const entries = await xata.db.markets
.filter({ $exists: "card.id" })
.getAll();
const entries = await xata.db.markets
.filter({ $exists: "card.id" })
.getAll();
Filtering records
Use the Xata SDK to filter across APIs for versatile functionality
kostas
kostas6mo ago
Similarly, notExists will do the opposite (select links without an id)
Oreki
OrekiOP6mo ago
my use case is to run a cron to delete all faulty market entries, this would not really happen but this is to be at a safer side
Want results from more Discord servers?
Add your server