fetchById
fetchById()
queries for a single entity by its id and returns the entity if it is found or null
if it is not. For example:
await client.insert('employees', { id: 'Fry', name: 'Philip J. Fry' });
await client.insert('employees', { id: 'Leela', name: 'Turanga Leela' });
const fry = await client.fetchById('employees', 'Fry', options); // { name: 'Philip J. Fry' }
const leela = await client.fetchById('employees', 'Leela', options); // { name: 'Turanga Leela' }
const bender = await client.fetchById('employees', 'Bender', options); // null
This is a convenient shorthand for applying a where('id', '=', id)
filter and extracting the result from the result set.