query add chain
This commit is contained in:
parent
1104efaa1a
commit
515c6e6cf7
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@kevisual/query",
|
"name": "@kevisual/query",
|
||||||
"version": "0.0.18",
|
"version": "0.0.19-beta.0",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"module": "dist/index.js",
|
"module": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
24
src/query.ts
24
src/query.ts
@ -225,10 +225,22 @@ export class Query {
|
|||||||
|
|
||||||
export { adapter };
|
export { adapter };
|
||||||
|
|
||||||
export class BaseQuery<T extends Query = Query> {
|
export class BaseQuery<T extends Query = Query, R extends { queryChain?: any; query?: any } = { queryChain: any; query?: T }> {
|
||||||
query: T;
|
query: T;
|
||||||
constructor({ query }: { query: T }) {
|
queryDefine: R;
|
||||||
this.query = query;
|
constructor(opts?: { query: T; queryDefine?: R; clientQuery?: T }) {
|
||||||
|
if (opts?.clientQuery) {
|
||||||
|
this.query = opts.clientQuery;
|
||||||
|
} else {
|
||||||
|
this.query = opts?.query;
|
||||||
|
}
|
||||||
|
if (opts.queryDefine) {
|
||||||
|
this.queryDefine = opts.queryDefine;
|
||||||
|
this.queryDefine.query = this.query;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
chain() {
|
||||||
|
return this.queryDefine.queryChain;
|
||||||
}
|
}
|
||||||
post<R = any, P = any>(data: P, options?: DataOpts): Promise<Result<R>> {
|
post<R = any, P = any>(data: P, options?: DataOpts): Promise<Result<R>> {
|
||||||
return this.query.post(data, options);
|
return this.query.post(data, options);
|
||||||
@ -237,3 +249,9 @@ export class BaseQuery<T extends Query = Query> {
|
|||||||
return this.query.get(data, options);
|
return this.query.get(data, options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class ClientQuery extends Query {
|
||||||
|
constructor(opts?: QueryOpts) {
|
||||||
|
super({ ...opts, url: opts?.url || '/client/router' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user