UNPKG

neo4-js

Version:

Neo4j graphdb object graph mapper for javascript

29 lines (28 loc) 1.48 kB
import { Model, ModelInstance } from "./index"; export declare type lazyModel<P, M extends ModelInstance<P>> = Model<P, M> | (() => Model<P, M> | null); export declare type metaRelation = { from: lazyModel<any, any>; to: lazyModel<any, any>; via: string; }; export declare type lazyMetaRelation = metaRelation | (() => metaRelation | null); export declare type relationProperty = { dest: lazyModel<any, any>; relation: lazyMetaRelation; out?: boolean; any?: boolean; propertyName: string; many: boolean; }; export declare const relation: { from: <P1, M1 extends ModelInstance<P1, {}>>(from: lazyModel<P1, M1>) => { to: <P2, M2 extends ModelInstance<P2, {}>>(to: lazyModel<P2, M2>) => { via: (via: string) => metaRelation; }; }; }; export declare const hasMany: <P, M extends ModelInstance<P, {}>>(model: lazyModel<P, M>, relation: lazyMetaRelation, direction?: "any" | "in" | "out") => (target: any, key: string) => void; export declare const hasOne: <P, M extends ModelInstance<P, {}>>(model: lazyModel<P, M>, relation: lazyMetaRelation, direction?: "any" | "in" | "out") => (target: any, key: string) => void; export declare const model: <P, M extends ModelInstance<P, {}>>(model: lazyModel<P, M>) => (target: any) => void; export declare const defaultProps: (props: any) => (target: any) => void; export declare function extendModelInstance<P, M extends ModelInstance<P>>(instance: new () => M): new () => M;