EasyFM - v5.0.0-beta.8
    Preparing search index...

    Query Recipes

    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();

    query 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 is 1-based
    • offset: 1 means first record

    Use 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:

    • which portals to include
    • where portal paging starts
    • how many rows per portal to fetch
    const operation = layout.records
    .list({
    portals: {},
    limit: 25,
    })
    .scripts({
    prerequest: database.script('PrepareContext'),
    after: database.script('AfterFetch'),
    });

    const records = await operation.fetch();

    Supports:

    • prerequest
    • presort
    • after

    Use 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.