UNPKG

neo4-js

Version:

Neo4j graphdb object graph mapper for javascript

52 lines (51 loc) 2.43 kB
import { ModelInstance, BaseProps, Optional, PropertiesType } from "./index"; import { CharGenerator } from "./utils"; export declare function createModelInstance<P, M extends ModelInstance<P, R>, R = {}>(model: Model<P, M>, props: P & BaseProps | null): M; export declare function createFakeModelInstance<P, M extends ModelInstance<P>>(model: Model<P, M>, charGenerator: CharGenerator): M; export declare type ChainItem = { model: Model<any, any>; fakeInstance: ModelInstance<any>; match: string; flatProps: any; result: string[]; where: string[]; variable: string; relationVariable?: string; next?: ChainItem; prev?: ChainItem; first?: ChainItem; hasOne?: boolean; propertyName?: string; firstOne?: boolean; }; export declare class IncludesQuery<M extends ModelInstance<any>> { chainItem: ChainItem; charGenerator: CharGenerator; constructor(chainItem: ChainItem, charGenerator: CharGenerator); include<P, R extends ModelInstance<P>>(fn: (m: M) => Promise<R[] | R>): IncludesQuery<R>; run(): Promise<any>; } export declare class Model<P, M extends ModelInstance<P>> { label: String; private relations; private modelInstanceClass; protected beforeCreate(props: P & BaseProps): P & BaseProps; protected afterCreate(instance: M): M; protected beforeFind(props?: Optional<PropertiesType<P & BaseProps>>): (Optional<PropertiesType<P & BaseProps>>) | null; protected afterFind(instance: M): M; protected beforeUpdate(props: Optional<PropertiesType<P & BaseProps>>, newProps: Optional<P>): { props: Optional<PropertiesType<P & BaseProps>>; newProps: Optional<P>; }; protected afterUpdate(instance: M): M; constructor(label: string); create(props: P): Promise<M>; findByGuidAndInclude(guid: string): IncludesQuery<M>; findByGuid(guid: string): Promise<M | null>; delete(props: Optional<PropertiesType<P & BaseProps>>, detach?: boolean): Promise<number>; findAndInclude(props?: Optional<PropertiesType<P & BaseProps>>): IncludesQuery<M>; find(props?: Optional<PropertiesType<P & BaseProps>>): Promise<M[]>; findOneAndInclude(props?: Optional<PropertiesType<P & BaseProps>>): IncludesQuery<M>; findOne(props?: Optional<PropertiesType<P & BaseProps>>): Promise<M | null>; update(props: Optional<PropertiesType<P & BaseProps>>, newProps: Optional<P>): Promise<M[]>; }