UNPKG

@jd-data-limited/easy-fm

Version:

easy-fm is a Node.js module that allows you to interact with a [FileMaker database stored](https://www.claris.com/filemaker/) on a [FileMaker server](https://www.claris.com/filemaker/server/). This module interacts with your server using the [FileMaker

55 lines (54 loc) 1.91 kB
/* * Copyright (c) 2023-2024. See LICENSE file for more information */ import { LayoutRecord } from '../records/layoutRecord.js'; import { RecordGetOperation } from '../records/getOperations/recordGetOperation.js'; /** * Manager class for handling layout records. */ export class LayoutRecordManager { layout; constructor(layout) { this.layout = layout; } /** * Creates a new layout record with the provided options. * * @param {OPTIONS} options - The options for creating the layout record. * @return {Promise<LayoutRecord<PickPortals<T, OPTIONS['portals'][number]>>>} * The newly created layout record. */ async create(options) { const metadata = await this.layout.getLayoutMeta(); const fields = {}; for (const _field of metadata.fieldMetaData) { fields[_field.name] = ''; } const portals = {}; for (const _portal of Object.keys(metadata.portalMetaData)) portals[_portal] = []; return new LayoutRecord(this.layout, -1, 0, fields, portals); } /** * Retrieves a layout record based on the given recordId. * * @param {number} recordId - The identifier of the record to retrieve. * * @returns {Promise<LayoutRecord<PickPortals<T, never>>>} - A Promise that resolves with the retrieved layout record. */ async get(recordId) { await this.layout.getLayoutMeta(); const record = new LayoutRecord(this.layout, recordId); await record.get(); return record; } /** * Creates a new instance of RecordGetOperation with the given options. * * @param {Array} options - An array of options for the operation. * @return {RecordGetOperation} - A new instance of RecordGetOperation. */ list(options) { return new RecordGetOperation(this.layout, options); } }