PalmyraGridStore#
@palmyralabs/palmyra-wire · PalmyraGridStore implements GridStore<any>
Overview#
Read-side store for paginated grids. Paged query, single-record get, a schema endpoint for column metadata, and a browser-driven export that opens a _format-suffixed URL in a new window.
Usually obtained via factory.getGridStore(...) rather than constructed directly.
Constructor#
new PalmyraGridStore(
baseUrl: string,
endPoint: IEndPoint,
options: StoreOptions,
factory?: APIErrorHandlerFactory,
idProperty?: strings,
)Methods#
| Method | Signature |
|---|---|
query |
query(request: QueryRequest): Promise<QueryResponse<any>> — GET with _offset/_limit/_orderBy/_total params |
queryLayout |
queryLayout(request: QueryRequest): Promise<any> — same URL, header action: 'schema'; returns column metadata |
get |
get(request: GetRequest, idProperty?: string): Promise<any> — GET a single row; unwraps response.data.result |
export |
export(request: ExportRequest): void — opens url?...&_format=csv|excel|pdf|doc in a new window |
getEndPoint |
getEndPoint(): IEndPoint |
getIdProperty |
getIdProperty(): string — hard-coded "id" (constructor arg is ignored) |
getIdentity |
getIdentity(o): any — throws Method not implemented |
Example#
import AppStoreFactory from './wire/StoreFactory';
const users = AppStoreFactory.getGridStore({}, '/user');
// paged query
const page = await users.query({
filter: { status: 'ACTIVE' },
sort: ['-createdAt'],
offset: 0,
limit: 25,
});
console.log(page.result.length, page.total);
// single row
const ada = await users.get({ id: 42 });
// schema for a dynamic column picker
const schema = await users.queryLayout({});
// export the current filter as CSV
users.export({ filter: { status: 'ACTIVE' }, format: 'csv' });Caveat — getIdProperty#
The implementation returns the literal string "id" regardless of what you pass into the constructor. If your rows key on something else, plumb the real id-property through your grid configuration instead of relying on store.getIdProperty().