@cubicweb/rql-generator
Version:
Helpers to build RQL queries
33 lines • 2.36 kB
TypeScript
import { EntityData } from "./types.js";
import { EntityRawSchemaArray, RelationDefinitionRawSchemaArray, RelationDefinitionSchema, ResultSet, ResultSetRow, Schema } from "@cubicweb/client";
/**
* Converts a raw RQL result set to a list of JavaScript object for representing entities.
*
* The given attributes and relations must be given in the same order as the values in the row.
*
* @param row The RQL result set representing the list of entities
* @param attributes The list of attributes matching the RQL row
* @param subjectRelations The list of subject reations matching the RQL row
* @param objectRelations The list of object relations matching the RQL row
* @returns An array of objects with attributes/relations as keys and their values as value
*
* @category Utilities
*/
export declare const rowsToEntities: (rows: ReadonlyArray<ResultSetRow>, attributes: ReadonlyArray<RelationDefinitionSchema>, subjectRelations: ReadonlyArray<RelationDefinitionSchema>, objectRelations: ReadonlyArray<RelationDefinitionSchema>) => Array<EntityData>;
/**
* Converts a raw RQL row to a JavaScript object for representing an entity.
*
* The given attributes and relations must be given in the same order as the values in the row.
*
* @param row The RQL result row representing the entity
* @param attributes The list of attributes matching the RQL row
* @param subjectRelations The list of subject reations matching the RQL row
* @param objectRelations The list of object relations matching the RQL row
* @returns An object with attributes/relations as keys and their values as value
*
* @category Utilities
*/
export declare function rowToEntity(row: ResultSetRow, attributes: ReadonlyArray<RelationDefinitionSchema>, subjectRelations: ReadonlyArray<RelationDefinitionSchema>, objectRelations: ReadonlyArray<RelationDefinitionSchema>): EntityData;
export declare function resultSetToEntity<E extends EntityRawSchemaArray, R extends RelationDefinitionRawSchemaArray<E>>(schema: Schema<E, R>, entityType: string, relations: string[], resultSet: ResultSet): EntityData;
export declare function resultSetToEntities<E extends EntityRawSchemaArray, R extends RelationDefinitionRawSchemaArray<E>>(schema: Schema<E, R>, entityType: string, resolve: string[] | undefined, resultSet: ResultSet): EntityData[];
//# sourceMappingURL=resultset.d.ts.map