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

48 lines (47 loc) 1.25 kB
/* * Copyright (c) 2024. See LICENSE file for more information */ import moment from 'moment'; export const FindRequestSymbol = Symbol('easyfm-findrequest'); const SPECIAL_CHARACTERS = ['\\', '=', '<', '≤', '≥', '>', '…', '...', '//', '@', '#', '*', '"', '~']; export function queryEscape(str) { for (const char of SPECIAL_CHARACTERS) { str = str.replace(char, `\\${char}`); } return str; } export function query(strings, ...args) { const argStrings = args.map(item => { if (typeof item === 'number') { return queryEscape(item.toString()); } else if (typeof item === 'string') return queryEscape(item); else return item; }); // Zip the parameters together const query = strings.map((str, index) => { return [str, (argStrings[index] || '')]; }).flat(1); return { [FindRequestSymbol]: query }; } export function asDate(date) { return { type: 'date', moment: moment(date) }; } export function asTime(date) { return { type: 'time', moment: moment(date) }; } export function asTimestamp(date) { return { type: 'timestamp', moment: moment(date) }; } query;