This project provides access to FileMaker Server databases using the XML Web publishing interface.
This package is a Vapor port of the Perfect-FileMaker project.
Ensure you have installed and activated the latest Swift 3.0 tool chain.
Ensure that you have installed curl and libxml2.
sudo apt-get install libcurl4-openssl-dev libxml2-dev
Add this project as a dependency in your Package.swift file.
.Package(url: "https://github.com/goto10/Vapor-FileMaker.git", majorVersion: 1, minor: 0)
To utilize this package, import VaporFileMaker
.
All responses come back as JSON and conform to ResponseRepresentable
This snippet connects to the server and has it list all of the hosted databases.
drop.get("dblist") { request in
let fms = FileMakerServer(host: testHost, port: testPort, userName: testUserName, password: testPassword)
return try fms.databaseNames()
}
List all of the layouts in a particular database.
let fms = FileMakerServer(host: testHost, port: testPort, userName: testUserName, password: testPassword)
let layoutList = try fms.layoutNames(database: dbName)
List all of the field names on a particular layout.
let fms = FileMakerServer(host: testHost, port: testPort, userName: testUserName, password: testPassword)
let layoutInfo = fms.layoutInfo(database: "FMServer_Sample", layout: "Task Details")
Perform a findall and print all field names and values.
let query = FMPQuery(database: "FMServer_Sample", layout: "Task Details", action: .findAll)
let fms = FileMakerServer(host: testHost, port: testPort, userName: testUserName, password: testPassword)
let results = fms.query(query)
To add skip and max, the query above would be amended as follows:
// Skip two records and return a max of two records.
let query = FMPQuery(database: "FMServer_Sample", layout: "Task Details", action: .findAll)
.skipRecords(2).maxRecords(2)
...
Find all records where the field "Status" has the value of "In Progress".
let qfields = [FMPQueryFieldGroup(fields: [FMPQueryField(name: "Status", value: "In Progress")])]
let query = FMPQuery(database: "FMServer_Sample", layout: "Task Details", action: .find)
.queryFields(qfields)
let fms = FileMakerServer(host: testHost, port: testPort, userName: testUserName, password: testPassword)
let results = fms.query(query)