Skip to content

Function FindOrFail

find or fail with multiple ids throws model not found exception

typescript
await FedacoTestUser.createQuery().create({
  id: 1,
  email: 'linbolen@gradii.com'
});
await expect(async () => {
  await FedacoTestUser.createQuery().findOrFail([1, 2]);
}).rejects.toThrowError(
  'ModelNotFoundException No query results for model [FedacoTestUser] [1,2]'
);

see also prerequisites

find or fail with single id throws model not found exception

typescript
await expect(async () => {
  await FedacoTestUser.createQuery().findOrFail(1);
}).rejects.toThrowError(
  'ModelNotFoundException No query results for model [FedacoTestUser] 1'
);

see also prerequisites

find or fail

typescript
await FedacoTestUser.createQuery().create({
  id: 1,
  email: 'linbolen@gradii.com'
});
await FedacoTestUser.createQuery().create({
  id: 2,
  email: 'xsilen@gradii.com'
});
const single = await FedacoTestUser.createQuery().findOrFail(1);
const multiple = await FedacoTestUser.createQuery().findOrFail([1, 2]);
ReferenceLooks LikeValue
single.emailexactly match'linbolen@gradii.com'
isArray(multiple)exactly matchtrue
multiple[0]instance type exactly matchFedacoTestUser
multiple[1]instance type exactly matchFedacoTestUser

see also prerequisites

Released under the MIT License.