This guide covers record listing, finding, paging, sorting, and portal fetches.
const records = await layout.records
.list({
portals: {},
limit: 25,
})
.fetch();
Without requests, library uses FileMaker GET /records.
With requests, library switches to FileMaker _find.
import { query as q } from '@jd-data-limited/easy-fm';
const records = await layout.records
.list({
portals: {},
requests: [
{
req: {
Status: q`Active`,
CustomerNumber: q`=${1234}`,
},
},
],
limit: 25,
})
.fetch();
queryquery is tagged template helper that escapes special FileMaker find characters while
still letting you embed values.
const email = 'ada@example.com';
const request = {
Email: q`${email}`,
};
Use it instead of manually building raw find strings.
Each request object acts like FileMaker find request block.
const operation = layout.records.list({
portals: {},
limit: 50,
});
operation.addRequest({
Status: q`Active`,
});
operation.addRequest({
Status: q`Pending`,
});
const records = await operation.fetch();
Use omit: true to exclude matched records.
const records = await layout.records
.list({
portals: {},
requests: [
{
req: {
Status: q`Archived`,
},
omit: true,
},
],
})
.fetch();
const records = await layout.records
.list({
portals: {},
limit: 25,
})
.sort('LastName', 'ascend')
.sort('FirstName', 'ascend')
.fetch();
Allowed sort order values:
"ascend""descend"const page2 = await layout.records
.list({
portals: {},
limit: 100,
offset: 101,
})
.fetch();
Important:
offset: 1 means first recordUse async iterator for large jobs:
const operation = layout.records.list({
portals: {},
limit: 5000,
});
for await (const record of operation.iterate(100)) {
console.log(record.recordId);
}
This fetches in pages instead of loading all rows at once.
const records = await layout.records
.list({
portals: {
LineItems: {
offset: 1,
limit: 50,
},
},
limit: 10,
})
.fetch();
Portal config means:
const operation = layout.records
.list({
portals: {},
limit: 25,
})
.scripts({
prerequest: database.script('PrepareContext'),
after: database.script('AfterFetch'),
});
const records = await operation.fetch();
Supports:
prerequestpresortafterUse helpers so library formats values with host timezone rules:
import { asDate, asTime, asTimestamp, query as q } from '@jd-data-limited/easy-fm';
const records = await layout.records
.list({
portals: {},
requests: [
{
req: {
StartDate: q`${asDate(new Date())}`,
UpdatedAt: q`${asTimestamp(new Date())}`,
},
},
],
})
.fetch();
Read timezones.md if results look shifted.