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

41 lines (40 loc) 1.4 kB
/* * Copyright (c) 2023-2024. See LICENSE file for more information */ import { RecordBase } from './recordBase.js'; import { RecordTypes } from '../types.js'; /** * Represents a PortalRecord, which is a record in a portal within a parent record. * @template T - The type of the record's field map. */ export class PortalRecord extends RecordBase { portal; type = RecordTypes.PORTAL; constructor(record, portal, recordId, modId = recordId, fieldData = {}) { super(record.layout, recordId, modId, fieldData); this.portal = portal; } _onSave() { super._onSave(); this.portal.record._onSave(); } /** * Commits the parent record, and in turn this one. * * @param {extraBodyOptions} [extraBody={}] - The optional extra body options. * @returns {Promise} - A promise that resolves when the record is committed. */ async commit(extraBody = {}) { return await this.portal.record.commit(extraBody); } toObject(fieldFilter) { const res = { recordId: this.recordId === -1 ? undefined : this.recordId.toString(), modId: this.modId === -1 ? undefined : this.modId.toString() }; for (const field of this.fieldsArray.filter(a => fieldFilter(a))) res[field.id] = field.value?.toString(); // console.log(res) return res; } }