npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@jd-data-limited/easy-fm

v4.1.6

Published

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

Downloads

407

Readme

Introduction

A FileMaker Data API client for NodeJS

easy-fm is a Node.js module that allows you to interact with a FileMaker database stored on a FileMaker server or FileMaker Cloud. This module interacts with your server using the FileMaker Data API.

Contents

Installation

npm install @jd-data-limited/easy-fm --save

easy-fm also requires the following to be configured within your FileMaker enviroment:

  1. Enable the FileMaker Data API from the server's admin console. This setting is located in Connectors > FileMaker Data API.
  2. Create a FileMaker database account for easy-fm to use. This account must have the 'Access via FileMaker Data API ( fmrest)' extended privilege

Usage

Connecting to a database

import FMHost from "easy-fm"; // Import the module
const host = new FMHost("https://<your-servers-address>")
const database = host.database({
    database: "your_database.fmp12",
    credentials: {
        method: "filemaker",
        username: "<username>",
        password: "<password>"
    },
    externalSources: []
})

// OPTIONAL - EasyFM will automatically attempt a login anyway when you perform your first operation
database.login().then(() => {

})

NOTE: A connection will only give you access to the layouts in the database you are connected to, and not the layouts in any external sources that you have specified.

If you need to interact with layouts on multiple databases, you need to open a separate connection for each.

An important note about timezones

Although it is recommended, timestamps in FileMaker databases are not always stored in UTC time. To account for this, EasyFM allows you to specify a function/method that determines the server's current timezone. EasyFM will use this timezone offset to convert timestamps to and from JavaScript Date objects.

import FMHost from "easy-fm";
import {type Moment} from 'moment'

const host = new FMHost("https://<your-servers-address>", (moment: Moment) => {

})

Getting records

One of (if not the) most common interactions you'll need to use is fetching records.

Fetch a range of records

let layout = database.getLayout("Your layout name")
let query = layout.records.list({
    portals: {
        test: {limit: 10, offset: 1} // Include results from the 'test' portal
    },
    limit: 10, // Limit result set to 10 records...
    offset: 30 // ...starting from the 30th record
})

let records = await query.fetch()
console.log(records)

Searching for records

Searching for records uses the same syntax as above, but with additional steps to add your search parameters.

let layout = database.getLayout("Your layout name")
let query = layout.records.list({
    portals: {
        test: {limit: 10, offset: 1} // Include results from the 'test' portal
    },
    limit: 10, // Limit result set to 10 records...
    offset: 30 // ...starting from the 30th record
})

query.addRequest({"GroupID": "=abc"}) // Add a filter

let records = await query.fetch()
console.log(records)

Fetch a record using its record ID (NOT RECOMMENDED)

Please note: When in FileMaker Pro, a record's ID is returned when using Get(RecordID). If you need to fetch a record using a different ID, use the search method above.

let layout = database.getLayout("Your layout name")
let record = await layout.records.get(164)
console.log(record)

Create a record

let layout = database.getLayout("Your layout name")
let record = await layout.records.create()

record.fields["Field1"].value = "Value here"
record.fields["Field2"].value = "Value here"
record.fields["Field3"].value = "Value here"

await record.commit()

Modify a record

let layout = database.getLayout("Your layout name")
let record = await layout.records.get(164)

record.fields["Field1"].value = "Value here"
record.fields["Field2"].value = "Value here"
record.fields["Field3"].value = "Value here"

await record.commit()

Field names

When interacting with FileMaker, it is important to remember how FileMaker field names work.

| Field name format | Use when.... | |-------------------------------|-----------------------------------------------------------------------------------------------------| | FieldName | Use this when the field you are accessing is in the same table that the layout has been assigned to | | RelatedTableName::FieldName | Use this when the field is not in the same table that the layout has been assigned to |

NOTE: You will not be able to access any fields that are not on the layout.

Portal names

Please read this section carefully if you are working with portals

It is important to note that a portal's name is not the same as the name of the table that it links to. The name of a portal matches the object name it was assigned in FileMaker's layout editor.

NOTE: When no name has been manually assigned to it, it will default to the name of the related table.

Typescript Implementation

easy-fm supports the use of TypeScript. Here's an example of how this works with easy-fm:

import FMHost, {Portal, Field, Container} from "@jd-data-limited/easy-fm";

interface UsersLayout {
    fields: {
        // Map each field on the layout to a field type.
        first_name: Field<string>
        age: Field<number>
        birthdate: Field<Date>
        profile_picture: Field<Container>
        "MyRelatedTable::MyRelatedField": Field<string>
    },
    portals: {
        Files: {
            "Files::Field1": Field<string>
        }
    }
}

interface DatabaseStructure {
    layouts: {
        users: UsersLayout
    }
}

const host = new FMHost("https://example_filemaker_server.com")
const database = host.database<DatabaseStructure>({
    database: "ExampleDatabase.fmp12",
    credentials: {method: "filemaker", username: "test", passsword: "test"},
    externalSources: []
})
await database.login()

const layout = database.getLayout("users") // The UsersLayout interface will be automatically applied to all records within this layout
const record = await layout.records.create()
record.fields["first_name"].value = "Joe"
record.fields["age"].value = 38