Rate this page:
The query builder API enables you to query the app storage API and returns filtered results.
Use the storage.query
method to start building a query.
1 2import { storage, startsWith } from '@forge/api'; await storage.query() // Filter the response to only keys that start with the string 'value' .where('key', startsWith('value')) // Limit the result size to 10 values .limit(10) // Use the cursor provided (returned from a previous invocation) .cursor('...') // Get a list of results .getMany();
The Query
object is immutable.
The Atlassian Cloud backs up the entire hosted storage for disaster recovery. This includes content stored from the Forge storage API.
We will add admin-driven backup (and restore) capabilities for app-level data in a future update.
Returns a new query with an additional predicate that returned values must match. Filters are applied server side and have the following restrictions:
key
field.where
condition for a query.startsWith
. Other more advanced conditions are only enabled by
custom entities (see Conditions for complex queries for information).If no conditions are supplied, the query iterates over all values.
1 2query.where(field: 'key', condition: Predicate): Query
Returns a new Query
with a limit on how many matching values get returned. The query
API returns up to 10 values by default, this can be increased to a maximum of 20.
1 2query.set(limit: number): Query
Returns a new Query
that will start after the provided cursor. Cursors enable your
app to fetch subsequent pages of results after completing an initial query.
Cursors are returned from the getMany
query API.
1 2query.cursor(after: string): Query;
Execute the query and return a list of results up to the provided limit in length. This method returns both the array of results and a cursor that's used to fetch subsequent pages of results.
1 2query.getMany(): Promise<ListResult>; interface ListResult { results: Result[]; nextCursor?: string; } export interface Result { key: string; value: object; }
Execute the query and get the first matching result, if any matches exist. If there
is no matching result the result resolves to undefined
.
1 2query.getOne(): Promise<Result | undefined>; export interface Result { key: string; value: object; }
Constructs a predicate used in the query.where
method to filter results. startsWith
enforces that the specified field must start with the specified string.
1 2startsWith(value: string): Predicate
Rate this page: