import { Class, Entity, juggler, Model, Repository } from '@loopback/repository'; import DataSource = juggler.DataSource; /** * Type definition for decorators returned by `@repository` decorator factory */ export type QueryDecorator = (target: Object, key?: string, descriptorOrIndex?: TypedPropertyDescriptor | number) => void; /** * Metadata for a query */ export declare class QueryMetadata { /** * Name of the predefined repository */ name?: string; /** * Name of the model */ modelName?: string; /** * Class of the model */ modelClass?: typeof Entity; /** * Name of the data source */ dataSourceName?: string; /** * Instance of the data source */ dataSource?: juggler.DataSource | DataSource; /** * Constructor for QueryMetadata * * @param modelOrRepo - Name or class of the model. If the value is a string and * `dataSource` is not present, it will be treated as the name of a predefined * select query * @param dataSource - Name or instance of the data source * * For example: * * - new QueryMetadata(repoName); * - new QueryMetadata(modelName, dataSourceName); * - new QueryMetadata(modelClass, dataSourceInstance); * - new QueryMetadata(modelName, dataSourceInstance); * - new QueryMetadata(modelClass, dataSourceName); */ constructor(modelOrRepo: string | typeof Entity, dataSource?: string | juggler.DataSource | DataSource); } /** * Decorator for query injections on properties or method arguments * * @example * ```ts * class CustomerController { * @query(CustomerRepository) public custQuery: Query; * * constructor( * @query(ProductRepository) public prodQuery: Query, * ) {} * * } * ``` * * @param repositoryName - Name of the repo */ export declare function query(repositoryName: string | Class>): QueryDecorator; /** * Decorator for Query generation and injection on properties * or method arguments based on the given model and dataSource (or their names) * * @example * ```ts * class CustomerController { * @query('Customer', 'mySqlDataSource') * public custQuery: Query; * * constructor( * @query(Product, mySqlDataSource) * public prodQuery: Query, * ) {} * } * ``` * * @param model - Name/class of the model * @param dataSource - Name/instance of the dataSource */ export declare function query(model: string | typeof Entity, dataSource: string | juggler.DataSource): QueryDecorator;