UNPKG

1.53 kBTypeScriptView Raw
1import { AnyObject, Command, NamedParameters, Options, PositionalParameters } from '../common-types';
2import { Model } from '../model';
3/**
4 * Interfaces adopted by a {@link Connector}.
5 *
6 * @experimental
7 */
8export declare namespace ConnectorInterfaces {
9 /**
10 * Strong relation interfaces adopted by a {@link Connector}
11 *
12 * @experimental
13 */
14 const enum StrongRelation {
15 BELONGS_TO = "strongBelongsTo",
16 HAS_ONE = "strongHasOne",
17 HAS_MANY = "strongHasMany",
18 HAS_MANY_THROUGH = "strongHasManyThrough",
19 HAS_AND_BELONGS_TO_MANY = "strongHasAndBelongsToMany",
20 EMBEDS_ONE = "strongEmbedsOne",
21 EMBEDS_MANY = "strongEmbedsMany",
22 REFERNCES_MANY = "strongReferencesMany"
23 }
24 /**
25 * Strong query join interfaces adopted by a {@link Connector}
26 *
27 * @experimental
28 */
29 const enum StrongJoins {
30 INNER = "strongInnerJoin",
31 LEFT = "strongLeftJoin",
32 RIGHT = "strongRightJoin",
33 FULL = "strongFullJoin",
34 CARTESIAN = "strongCartesianJoin"
35 }
36}
37/**
38 * Common properties/operations for connectors
39 */
40export interface Connector {
41 name: string;
42 configModel?: Model;
43 interfaces?: (string | ConnectorInterfaces.StrongRelation | ConnectorInterfaces.StrongJoins)[];
44 connect(): Promise<void>;
45 disconnect(): Promise<void>;
46 ping(): Promise<void>;
47 execute?(command: Command, parameters: NamedParameters | PositionalParameters, options?: Options): Promise<AnyObject>;
48}