Function Oldest
basic model collection retrieval
typescript
await FedacoTestUser.createQuery().create({
id: 1,
email: 'linbolen@gradii.com'
});
await FedacoTestUser.createQuery().create({
id: 2,
email: 'xsilen@gradii.com'
});
const models = await new FedacoTestUser().NewQuery().oldest('id').get();
Reference Looks Like Value isArray(models)exactly match truemodels[0]instance type exactly match FedacoTestUsermodels[1]instance type exactly match FedacoTestUsermodels[0].emailexactly match 'linbolen@gradii.com'models[1].emailexactly match 'xsilen@gradii.com'
see also prerequisites
paginated model collection retrieval when no elements and default per page
typescript
const models = await new FedacoTestUser().NewQuery().oldest('id').paginate();see also prerequisites
paginated model collection retrieval when no elements
typescript
// Paginator.currentPageResolver(() => {
// return 1;
// });
let models = await new FedacoTestUser().NewQuery().oldest('id').paginate(1, 2);typescript
// expect(models).toInstanceOf(LengthAwarePaginator);
// Paginator.currentPageResolver(() => {
// return 2;
// });
models = await new FedacoTestUser().NewQuery().oldest('id').paginate(2, 2);see also prerequisites
paginated model collection retrieval
typescript
await new FedacoTestUser().NewQuery().create({
id: 1,
email: 'linbolen@gradii.com'
});
await new FedacoTestUser().NewQuery().create({
id: 2,
email: 'xsilen@gradii.com'
});
await new FedacoTestUser().NewQuery().create({
id: 3,
email: 'foo@gmail.com'
});
// Paginator.currentPageResolver(() => {
// return 1;
// });
let models = await new FedacoTestUser().NewQuery().oldest('id').paginate(1, 2);
Reference Looks Like Value models.items[0]instance type exactly match FedacoTestUsermodels.items[1]instance type exactly match FedacoTestUsermodels.items[0].emailexactly match 'linbolen@gradii.com'models.items[1].emailexactly match 'xsilen@gradii.com'
Reference Looks Like Value models.items.lengthexactly match 1models.items[0]instance type exactly match FedacoTestUsermodels.items[0].emailexactly match 'foo@gmail.com'
see also prerequisites
pluck with column name containing a space
typescript
await FedacoTestUserWithSpaceInColumnName.createQuery().create({
id: 1,
email_address: 'linbolen@gradii.com'
});
await FedacoTestUserWithSpaceInColumnName.createQuery().create({
id: 2,
email_address: 'xsilen@gradii.com'
});
const simple = await FedacoTestUserWithSpaceInColumnName.createQuery()
.oldest('id')
.pluck('users_with_space_in_colum_name.email_address');
const keyed = await FedacoTestUserWithSpaceInColumnName.createQuery()
.oldest('id')
.pluck('email_address', 'id');
Reference Looks Like Value keyedmatch `({
1: 'linbolen@gradii.com',
2: 'xsilen@gradii.com'
});` |
see also prerequisites
pluck
typescript
await FedacoTestUser.createQuery().create({
id: 1,
email: 'linbolen@gradii.com'
});
await FedacoTestUser.createQuery().create({
id: 2,
email: 'xsilen@gradii.com'
});
const simple = await FedacoTestUser.createQuery()
.oldest('id')
.pluck('users.email');
const keyed = await FedacoTestUser.createQuery()
.oldest('id')
.pluck('users.email', 'users.id');
Reference Looks Like Value keyedmatch `({
1: 'linbolen@gradii.com',
2: 'xsilen@gradii.com'
});` |
see also prerequisites