import { InputRelationshipOption, RelationBreakerMethod, RelationBreakerSetting, RelationBuilderMethod, RelationshipConfigTable, RelationshipFromJDL } from './interface/relation.interface'; import { Entity } from './entity'; /** * 『只要描述直接關聯的那條線的關係是什麼』 * 關係會關聯到三層 * 舉例就是問 Group時會知道有哪些 User (G->D->E->U) * Group.userMap (✔) * Group.departmentMap.employeeMap.user (✘) * * 參考 jhipster * 關係有四種: OneToOne, OneToMany, ManyToOne, ManyToMany * 以建立雙向為主 By Reference * https://tinyurl.com/ycksdjh2 * * 參考 SQL * FOREIGN KEY ... REFERENCES * https://tinyurl.com/2bfse55t */ export declare const DefaultRelationBreakerSetting: RelationBreakerSetting; /** * 要用這有個前提 * 要像 SQL一樣在 多對一時,多的那邊會記住一的 id * 如用 neo4j等資料庫,在資料庫可以不用這樣記 * 但是透過 cypher拉資料回來時,把關係對象的 id寫入 return res * 這邊所有的 config也要與 neo4j設定一致 * * *修正一下:應該是 neo4j cypher要參照此 config */ declare class _Relation { private _name; private static instance; static getInstance: () => _Relation; /** * Example: * relationship OneToOne { * JobHistory{job} to Job * JobHistory{department} to Department * JobHistory{employee} to Employee * } */ private _RelationshipFromJDL; private _RelationshipConfigTable; get RelationshipFromJDL(): RelationshipFromJDL; set RelationshipFromJDL(RelationshipFromJDL: RelationshipFromJDL); get RelationshipConfigTable(): RelationshipConfigTable; set RelationshipConfigTable(RelationshipConfigTable: RelationshipConfigTable); private constructor(); /** * https://www.jhipster.tech/managing-relationships/ */ toJDLFormat(config: any): void; /** * Regexp with string match or matchAll. * * e.g. * User{employee(userId)} to Employee{user(id)} * entity: User{ * relationshipName: {employee * referenceDisplay: (id * */ regexpMap: { JDLFormatBasic: RegExp; JDLFormatWith: RegExp; JDLFormatRequired: RegExp; JDLCurlyBrackets: RegExp; JDLCurlyBracketsRorL: RegExp; JDLParentheses: RegExp; JDLParenthesesRorL: RegExp; JDLEntity: RegExp; JDLRelationshipName: RegExp; JDLReferenceDisplay: RegExp; }; /** * * @param RelationshipFromJDL * @returns * * e.g. * RelationshipFromJDL { * OneToMany: Set(["User{employeeMap(userId)} to Employee{user(id)}"]) * } * ### It will turn into * UserRel = [ * { * "targetEntity": "Employee", * "relationshipName": "employee", * "type": "OneToMany", * "referencesEntity": "user" * } * ] */ fromJDL: (relationshipFromJDL: RelationshipFromJDL, options?: { isTreatSameManyToOneAndOneToMany: boolean; }) => void; switchRelationshipOptions: (options: InputRelationshipOption) => InputRelationshipOption; checkOptions(entity: any, options: InputRelationshipOption): void; /** * 通用建立關係的方法 * @param param0 * @param options * @returns */ buildRelationship: RelationBuilderMethod; /** * 當自己和對方的關係是"一對一"或者是"多對一"的時候 * 要把對方 set * @param param0 * @param options * @param count * @returns */ setRelationship: RelationBuilderMethod; /** * 當自己和對方的關係是"一對多"或者是"多對多"的時候 * 要把對方 add 進來 * @param param0 * @param options * @param count * @returns */ addRelationships: RelationBuilderMethod; breakInputEntityRelationships: RelationBreakerMethod; breakEntityRelationshipByOptions: RelationBreakerMethod; breakAllEntityRelationships: (thisEntity: Entity) => void; } export declare const Relation: _Relation; export {};