Skip to content

Commit

Permalink
Added invoke
Browse files Browse the repository at this point in the history
  • Loading branch information
ackava committed Aug 2, 2024
1 parent c487f57 commit 01c3f68
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/services/BaseEntityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ export interface IModelSchema {
keys: IColumn[];
properties: IColumn[];
relations: IRelation[];
readonly methods?: string[];
}

export interface IModel<T> {
Expand Down Expand Up @@ -340,7 +341,7 @@ export default abstract class BaseEntityService extends HttpSession {
}

public query<T extends IClrEntity>(m: IModel<T>,
queryFunction?: string,
queryFunction?: IModel<T>["schema"]["methods"][number],
... args: any[]): Query<T> {
return new Query({
service: this,
Expand All @@ -361,6 +362,17 @@ export default abstract class BaseEntityService extends HttpSession {
return this.putJson({url, body});
}

public invoke<T extends IClrEntity>(m: IModel<T>, method: IModel<T>["schema"]["methods"][number],entity: IClrEntity, ... args: any[]) {
return this.postJson({
url: `${this.url}invoke/${entity.$type}/${name}`,
method: "POST",
body: {
entity,
args
}
});
}

public save<T extends IClrEntity>(body: T, cloner?: (c: Cloner<T>) => Cloner<T>, trace?: boolean): Promise<T>;
public save<T extends IClrEntity>(body: T[], cloner?: (c: Cloner<T>) => Cloner<T>, trace?: boolean): Promise<T[]>;
public async save(body: any, cloner?: (c: Cloner<any>) => Cloner<any>, trace?: boolean): Promise<any> {
Expand Down

0 comments on commit 01c3f68

Please sign in to comment.