Filemaker Library (filemaker-lib)
This project is a Rust library (filemaker-lib
) designed to interact with the FileMaker Data API. It provides a simple API to perform key operations against FileMaker databases, such as fetching records, performing searches, updating records, deleting records, and manipulating database sessions.
Features
- Database Interaction: Fetch the list of available databases.
- Authentication: Securely manage session tokens for interacting with the FileMaker Data API.
- Record Management:
- Fetch records (paginated or all at once).
- Search for records based on custom queries and sorting criteria.
- Add single or multiple records.
- Update specific records.
- Delete records from a database.
- Database Layouts: Retrieve the layouts available in a given database.
- Database Clearing: Delete all records within a database.
- Advanced Querying and Sorting: Search with advanced queries and sort results in ascending or descending order.
- Utility Functions: Extract field names from records and encode database parameters safely.
Installation
Add filemaker-lib
to your project's Cargo.toml
:
[]
= "0.1.0"
or using git
[]
= { = "https://github.com/Drew-Chase/filemaker-lib.git"}
Usage
Initialization
To create a Filemaker
instance, you need to pass valid credentials (username and password), the name of the database, and the table you want to work with:
use Filemaker;
use Result;
async
Fetching Records
Retrieve specific records with pagination:
let records = filemaker.get_records.await?;
println!;
Fetch all records at once:
let all_records = filemaker.get_all_records.await?;
println!;
Adding Records
Adding a Single Record
To add a single record to your FileMaker database:
use Value;
use HashMap;
let mut single_record_data = new;
single_record_data.insert;
single_record_data.insert;
let result = filemaker.add_record.await?;
println!;
Adding Multiple Records
To add multiple records to your FileMaker database:
use Value;
use HashMap;
let records = vec!;
for in records.into_iter.enumerate
Counting Records
Count the total number of records available in the table:
let total_records = filemaker.get_number_of_records.await?;
println!;
Searching Records
Perform a query with search parameters and sorting:
use HashMap;
let mut query = new;
query.insert;
let sort_fields = vec!;
let ascending = true;
let search_results = filemaker..await?;
println!;
Updating Records
Update a record by its ID:
use Value;
let record_id = 123;
let mut field_data = new;
field_data.insert;
let update_result = filemaker.update_record.await?;
println!;
Deleting Records
Delete a record by its ID:
let record_id = 123;
filemaker.delete_record.await?;
println!;
Fetching Available Layouts
Retrieve a list of layouts in the specified database:
let layouts = get_layouts.await?;
println!;
Fetching Databases
Retrieve the list of databases accessible with your credentials:
let databases = get_databases.await?;
println!;
Clearing the Database
Delete all records from the current database and table:
filemaker.clear_database.await?;
println!;
Environment Variables
The library uses the FM_URL
environment variable to specify the base URL of the FileMaker server. You need to set this variable before using the library:
;
set_var
Replace "https://fm.example.com/fmi/data/vLatest"
with the actual URL of your FileMaker server.
Examples
This library comes with example implementations usable as references:
- Fetch List of Databases:
get_databases
- Fetch Layouts from a Database:
filemaker_layout_fetcher
- Retrieve Records:
main_filemaker
- Add Single Record:
filemaker_single_record_adder
- Add Multiple Records:
filemaker_multiple_record_adder
- Update Database Records:
filemaker_record_updater
- Delete Database Records:
filemaker_record_deleter
- Find Records Based on Query:
filemaker_search_results_output
Logging
The library uses the log
crate for logging. To capture and display logs, set up a logging framework such as env_logger
. Example:
use env_logger;
License
This library is licensed under the terms of the license detailed in the LICENSE
file.
For more information, please refer to the repository documentation. Contributions are welcome!