Key-Value Store
Custom Entity Store
SQL (EAP)
Cache (EAP)

Forge SQL is now available as part of our Early Access Program (EAP).

Forge SQL is an experimental feature offered to selected users for testing and feedback purposes. This feature is unsupported and subject to change without notice. Do not use Forge SQL in apps that handle sensitive information (including personally identifiable information) and customer data.

For more details, see Forge EAP, Preview, and GA.

Error handling for Forge SQL

The @forge/sql package exports error codes. The following example shows how the package handles a QUERY_TIMED_OUT error:

1
2
import sql, { errorCodes } from '@forge/sql'; 

try { 
  await sql
    .prepare("INSERT INTO city (id, city, population) VALUES (?, ?, ?)")
    .bindParams(1, "Beijing", 100)
    .execute();
} 
catch (error) { 
  if (error.code === errorCodes.QUERY_TIMED_OUT) { 
    // Handle query timeout
  } 
} 
Error code
Description
QUERY_TIMED_OUTThe provided query took more than 2 seconds to execute.
During EAP, executing queries that run for more than 10 seconds will trigger a QUERY_TIMED_OUT error. This occurs because the HTTP connection is being terminated, but the query continue executing at the database level.
SQL_EXECUTION_ERRORThe provided query was either incorrect or could not be executed at the database level.
More details are present in the  debug field.
INVALID_SQL_QUERYThe provided query is not compliant with ANSI SQL.
APP_NOT_ENABLEDForge SQL is not enabled on the app. To enable Forge SQL, register your app by submitting its app.id through our EAP signup form.

Rate this page: