Skip to main content

Query actions

List and explanation of JSON DB API actions for querying data

List and explanation of the "getRecords..." actions in the JSON DB API, which query data in FairCom database tables. Each action is a specific technique optimized to find and retrieve records quickly and efficiently. These actions work for all FairCom products that include the FairCom database engine.

Get data

These actions are part of the JSON DB API. This section provides actions to query records in tables. Most actions can directly return data or return a cursor that you can use to paginate forward and backward through the records. You can look up records by ID, find records that most closely match a key, retrieve all records in a table, retrieve records in index order, retrieve records within a key range, and retrieve records returned by a SQL query. These actions work with all tables, including FairCom Edge's integration tables.

Action

Description

closeCursor

"closeCursor" closes a previously opened cursor.

getRecordsByIds

"getRecordsByIds" directly returns records from a database using their primary key, which can be one or more fields.

This action treats a table as a simple key-value store when the primary key is the "id" field. Use "getRecordsFromCursor" to treat a table as a hierarchical-key-value store.

This action is the fastest way to retrieve records by ID or a multi-field primary key.

getRecordsByIndex

"getRecordsByIndex" typically returns a cursor that quickly retrieves records in index order. The server can optionally filter records using a SQL-like filter expression before returning them. The cursor can efficiently paginate through thousands of records at a time. The cursor can fetch records forward and backward and skip records in both directions.

This action can also efficiently return all records in one call when the table contains tens of thousands of records. The records can be sorted forward or backward in index order.

getRecordsByPartialKeyRange

"getRecordsByPartialKeyRange" retrieves records from a database table that match a partial key in the specified index. The server can optionally filter records using a SQL-like filter expression before returning them.

This action can efficiently return all matching records in one call, which is helpful for typeahead queries. The records are sorted forward or backward in index order. It can also return a cursor when you expect matching records to exceed tens of thousands of records.

getRecordsByTable

"getRecordsByTable" quickly retrieves records from a database table in table order. The server can optionally filter records using a SQL-like filter expression before returning them.

This action is the fastest way to retrieve all records in a table in one call. It can also return a forward-only cursor for paginating through tables containing more than tens of thousands of records.

getRecordsFromCursor

"getRecordsFromCursor" retrieves records from a cursor returned from another "getRecords..." action. A cursor can efficiently retrieve thousands of records at a time.

This action is the fastest way to paginate through records, tail the last N records, repeatedly read the same N records, skip records, and fetch records forward or backward. Both skip and fetch can move forward or backward in any combination, such as skipping ahead and fetching backward. Some actions create forward-only cursors.

getRecordsInKeyRange

"getRecordsInKeyRange" retrieves records from a database table within an index's specified range of keys. The specified index may contain multiple fields. The server matches index keys against partial or complete values. The upper or lower bounds of the key range can be set or omitted. The server can filter records using a SQL-like filter expression before returning them.

This action is the fastest way to retrieve a bounded set of records in index order. Use this action to treat a table as a hierarchical-key-value store. Use "getRecordsByIds" to treat a table as a simple key-value store.

getRecordsStartingAtKey

"getRecordsStartingAtKey" retrieves records from a database table starting with the record that most closely matches the specified key in the selected index.

This action is the fastest way to start at a specific key and walk records in index order. It is typically used to look up records that are near a key. It can also retrieve records before and after a key value.

getRecordsUsingSQL

"getRecordsUsingSQL" uses SQL to retrieve records. It can return a cursor that retrieves records forward and backward in SQL query order. The cursor can efficiently retrieve thousands of records at a time. The cursor can fetch records forward and backward and skip records.

This action is the fastest way to join tables, run complex filters, sort data using unindexed fields, and run analytic queries.

Tip

When you want to paginate through the query results, return a cursor from a "getRecords..." action and call the "getRecordsFromCursor" action repeatedly until the "moreRecords" property is false.

Note

For various reasons, the  "moreRecords" property may be true when no more records exist. An application should handle the case when the "getRecordsFromCursor" action returns no records.

This section lists the JSON actions that query data in FairCom database tables with getRecords... actions

query actions
getRecords
JSON DB API
API actions
jsonAction
get records by ids
get records by table
get records by index
get records starting at key
get records in key range
get records by partial key range
get records using sql
get records from cursor
close cursor