odm-client 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/client/cloudbase-client.d.ts +1 -0
  2. package/dist/client/mongodb-client.d.ts +1 -0
  3. package/dist/{cloudbase-index.cjs → cloudbase.cjs} +1 -1
  4. package/dist/cloudbase.d.ts +1 -0
  5. package/dist/{cloudbase-index.js → cloudbase.js} +37 -25
  6. package/dist/{index2.cjs → generate.cjs} +6 -5
  7. package/dist/generate.d.ts +1 -0
  8. package/dist/{index2.js → generate.js} +17 -16
  9. package/dist/index.cjs +1 -1
  10. package/dist/index.d.ts +0 -3
  11. package/dist/index.js +13 -19
  12. package/dist/{mongodb-index.cjs → mongodb.cjs} +2 -2
  13. package/dist/mongodb.d.ts +1 -0
  14. package/dist/{mongodb-index.js → mongodb.js} +8 -4
  15. package/package.json +16 -1
  16. /package/dist/deps/{_commonjsHelpers-KaVRbhAgd4-5e44xjkup.js → _commonjsHelpers-KaVRbhAgd4-70zzshp9b.js} +0 -0
  17. /package/dist/deps/{_commonjsHelpers-KaVRbhAgd4-bqfwq0htn.js → _commonjsHelpers-KaVRbhAgd4-res8ony5t.js} +0 -0
  18. /package/dist/deps/{acorn-DYjaOAP8Gz-c1zv3fupp.js → acorn-DYjaOAP8Gz-fpcmmyt75.js} +0 -0
  19. /package/dist/deps/{acorn-DYjaOAP8Gz-yd9wbp0u1.js → acorn-DYjaOAP8Gz-l01xlmx0w.js} +0 -0
  20. /package/dist/deps/{angular-1bp1uAROl4-8g0c11l56.js → angular-1bp1uAROl4-chbuw4r6h.js} +0 -0
  21. /package/dist/deps/{angular-1bp1uAROl4-9ivn4c5b3.js → angular-1bp1uAROl4-xjez32hd5.js} +0 -0
  22. /package/dist/deps/{babel-_P9jsDBVVy-h9th63jz9.js → babel-_P9jsDBVVy-2yg3c3b7n.js} +0 -0
  23. /package/dist/deps/{babel-_P9jsDBVVy-89klf6zkq.js → babel-_P9jsDBVVy-gh7w5yta8.js} +0 -0
  24. /package/dist/deps/{estree-Q-oFBmJEml-bwlnamlux.js → estree-Q-oFBmJEml-fsfbvfibz.js} +0 -0
  25. /package/dist/deps/{estree-Q-oFBmJEml-rqdkbjor8.js → estree-Q-oFBmJEml-vi8e4c16l.js} +0 -0
  26. /package/dist/deps/{flow-j77MFvzLrn-bw2xq88jp.js → flow-j77MFvzLrn-ljbwxlbx6.js} +0 -0
  27. /package/dist/deps/{flow-j77MFvzLrn-9l22ilt66.js → flow-j77MFvzLrn-rz2mp7fwm.js} +0 -0
  28. /package/dist/deps/{glimmer-ewQPb5nTUl-l9fzegsk9.js → glimmer-ewQPb5nTUl-swqp20fyl.js} +0 -0
  29. /package/dist/deps/{glimmer-ewQPb5nTUl-0skyrfotb.js → glimmer-ewQPb5nTUl-wafxvcg8d.js} +0 -0
  30. /package/dist/deps/{graphql-8EXR1_taGG-mope94e2h.js → graphql-8EXR1_taGG-072rubu6y.js} +0 -0
  31. /package/dist/deps/{graphql-8EXR1_taGG-10lynn1ml.js → graphql-8EXR1_taGG-i3wmfpne3.js} +0 -0
  32. /package/dist/deps/{html-dGbiW_CFWL-1tqgharao.js → html-dGbiW_CFWL-bp9vlk1kr.js} +0 -0
  33. /package/dist/deps/{html-dGbiW_CFWL-zmtfculbf.js → html-dGbiW_CFWL-k3g9oy2c5.js} +0 -0
  34. /package/dist/deps/{markdown-vAYIRClyWZ-z48qcj07n.js → markdown-vAYIRClyWZ-c7vkwmbjh.js} +0 -0
  35. /package/dist/deps/{markdown-vAYIRClyWZ-qeglajr0z.js → markdown-vAYIRClyWZ-z6hbtj81z.js} +0 -0
  36. /package/dist/deps/{meriyah-d5_qqf88x--ayvczp9za.js → meriyah-d5_qqf88x--1vh4l145g.js} +0 -0
  37. /package/dist/deps/{meriyah-d5_qqf88x--s495t5yup.js → meriyah-d5_qqf88x--r70sg2xzw.js} +0 -0
  38. /package/dist/deps/{postcss-Vz5bDQ3hJO-jsw4ivkia.js → postcss-Vz5bDQ3hJO-a81conqgc.js} +0 -0
  39. /package/dist/deps/{postcss-Vz5bDQ3hJO-75l8k0pnu.js → postcss-Vz5bDQ3hJO-hu3djwl2q.js} +0 -0
  40. /package/dist/deps/{query-builder-h6B2D2BCoQ-hi672ju0i.js → query-builder-h6B2D2BCoQ-md9vwh2qw.js} +0 -0
  41. /package/dist/deps/{query-builder-h6B2D2BCoQ-33f97qk7e.js → query-builder-h6B2D2BCoQ-zzx9xwrhd.js} +0 -0
  42. /package/dist/deps/{typescript-2hCq12HCbJ-kcwi4a0yz.js → typescript-2hCq12HCbJ-i2im1m0zb.js} +0 -0
  43. /package/dist/deps/{typescript-2hCq12HCbJ-q6p9eige4.js → typescript-2hCq12HCbJ-n3fmg7w0v.js} +0 -0
  44. /package/dist/deps/{yaml-I5o0CrcX7J-93fx0pyvm.js → yaml-I5o0CrcX7J-fi8ekhimn.js} +0 -0
  45. /package/dist/deps/{yaml-I5o0CrcX7J-d0drtacrr.js → yaml-I5o0CrcX7J-lsxhbyw7g.js} +0 -0
@@ -45,4 +45,5 @@ export declare class CloudBaseClient {
45
45
  count(tableName: string, args?: {
46
46
  where?: Record<string, any>;
47
47
  }): Promise<number>;
48
+ aggregate(tableName: string, pipeline: any[]): Promise<any[]>;
48
49
  }
@@ -63,4 +63,5 @@ export declare class MongoDbClient {
63
63
  count(tableName: string, args?: {
64
64
  where?: Record<string, any>;
65
65
  }): Promise<number>;
66
+ aggregate(tableName: string, pipeline: any[]): Promise<any[]>;
66
67
  }
@@ -1 +1 @@
1
- "use strict";var q=Object.defineProperty;var C=(l,t,e)=>t in l?q(l,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[t]=e;var f=(l,t,e)=>C(l,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./deps/query-builder-h6B2D2BCoQ-hi672ju0i.js");class O{constructor(t,e,r){f(this,"client");f(this,"schemaMeta");f(this,"context");f(this,"fieldMetaMap",{});f(this,"idField","_id");this.client=t,this.schemaMeta=e,this.context=r,this.fieldMetaMap=Object.entries(e).reduce((c,[n,i])=>(c[n]=i.columns.reduce((d,u)=>(d[u.name]=u,d),{}),c),{})}async findUnique(t,{where:e,select:r}){var d,u,s,w;const c=Object.keys(e??{});if(c.length===1&&c[0]===this.idField){if(r){const y=await this.client.collection(t).doc(e[this.idField]).field(r).get();return((d=y==null?void 0:y.data)==null?void 0:d[0])??null}const a=await this.client.collection(t).doc(e[this.idField]).get();return((u=a==null?void 0:a.data)==null?void 0:u[0])??null}const n=h.QueryBuilder.buildCloudBaseQuery(e,this.fieldMetaMap[t]);if(r){const a=await this.client.collection(t).where(n).field(r).get();return((s=a==null?void 0:a.data)==null?void 0:s[0])??null}const i=await this.client.collection(t).where(n).get();return((w=i==null?void 0:i.data)==null?void 0:w[0])??null}async findUniqueOrThrow(t,{where:e,select:r}){const c=await this.findUnique(t,{where:e,select:r});if(!c)throw new Error("Data Not Found");return c}async findFirst(t,e){const{data:r}=await this.findManyInner(t,{where:e==null?void 0:e.where,orderBy:e==null?void 0:e.orderBy,select:e==null?void 0:e.select,limit:1,offset:0});return(r==null?void 0:r[0])??null}async findFirstOrThrow(t,e){const r=await this.findFirst(t,e);if(!r)throw new Error("Data Not Found");return r}getFindQuery(t,e){const r=h.QueryBuilder.buildCloudBaseQuery((e==null?void 0:e.where)??{},this.fieldMetaMap[t]),c=h.QueryBuilder.getOrderByArray(e==null?void 0:e.orderBy);let n;return e!=null&&e.select?n=this.client.collection(t).where(r).field(e==null?void 0:e.select).skip((e==null?void 0:e.offset)??0):n=this.client.collection(t).where(r).skip((e==null?void 0:e.offset)??0),(e==null?void 0:e.limit)!=null&&(n=n.limit(e.limit)),c.length>0&&c.forEach(i=>{n=n.orderBy(i.fieldName,i.order)}),n}async findManyInner(t,e){return await this.getFindQuery(t,e).get()}async findMany(t,e){const r=e==null?void 0:e.where,c=e==null?void 0:e.orderBy,n=e==null?void 0:e.select,{data:i}=await this.findManyInner(t,{where:r,orderBy:c,select:n,limit:1e3,offset:0});return i}async findPage(t,e){const c=(e==null?void 0:e.limit)||10;if(c>1e3)throw new Error("limit must be less than or equal to 1000");const n=e==null?void 0:e.where,i=e==null?void 0:e.orderBy,d=(e==null?void 0:e.page)||1,u=e==null?void 0:e.select,s=(d-1)*c,w=this.findManyInner(t,{where:n,orderBy:i,select:u,limit:c,offset:s}),a=this.count(t,{where:n}),{data:y}=await w,B=await a,M=Math.ceil(B/c);return{data:y,total:B,page:d,pageCount:M,limit:c,hasPrev:d>1,hasNext:d<M}}async create(t,{data:e}){const r=h.applyDefaultValues(e,this.schemaMeta[t],this.context),c=await this.client.collection(t).add(r);return{_id:(c==null?void 0:c.id)??(c==null?void 0:c[this.idField])}}async update(t,{where:e,data:r}){const c=h.applyUpdateValues(r,this.schemaMeta[t]),n=Object.keys(e??{});if(n.length===1&&n[0]===this.idField){await this.client.collection(t).doc(e[this.idField]).update(c);return}const i=h.QueryBuilder.buildCloudBaseQuery(e,this.fieldMetaMap[t]);await this.client.collection(t).where(i).update(c)}async delete(t,{where:e}){const r=Object.keys(e??{});if(r.length===1&&r[0]===this.idField)return await this.client.collection(t).doc(e[this.idField]).remove();const c=h.QueryBuilder.buildCloudBaseQuery(e,this.fieldMetaMap[t]);await this.client.collection(t).where(c).remove()}async count(t,e){try{const r=this.getFindQuery(t,{where:e==null?void 0:e.where,offset:0}),{total:c}=await r.count();return c}catch(r){throw console.error("count error:",r),r}}}function F(l,t,e){const r=new O(l,t,e),c={};return Object.keys(t).forEach(n=>{c[n]={findUnique:i=>r.findUnique(n,i),findUniqueOrThrow:i=>r.findUniqueOrThrow(n,i),findFirst:i=>r.findFirst(n,i),findFirstOrThrow:i=>r.findFirstOrThrow(n,i),findMany:i=>r.findMany(n,i),findPage:i=>r.findPage(n,i),create:i=>r.create(n,i),update:i=>r.update(n,i),delete:i=>r.delete(n,i),count:i=>r.count(n,i)}}),c.$transaction=async n=>{const i=await l.startTransaction();try{const d=F(i,t,e);d.$transaction=void 0;const u=await n(d);return await i.commit(),u}catch(d){throw await i.rollback(),d}},c}exports.createCloudBaseClient=F;
1
+ "use strict";var q=Object.defineProperty;var g=(l,t,e)=>t in l?q(l,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[t]=e;var s=(l,t,e)=>g(l,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./deps/query-builder-h6B2D2BCoQ-md9vwh2qw.js");class C{constructor(t,e,r){s(this,"client");s(this,"schemaMeta");s(this,"context");s(this,"fieldMetaMap",{});s(this,"idField","_id");this.client=t,this.schemaMeta=e,this.context=r,this.fieldMetaMap=Object.entries(e).reduce((c,[n,i])=>(c[n]=i.columns.reduce((d,a)=>(d[a.name]=a,d),{}),c),{})}async findUnique(t,{where:e,select:r}){var d,a,f,w;const c=Object.keys(e??{});if(c.length===1&&c[0]===this.idField){if(r){const y=await this.client.collection(t).doc(e[this.idField]).field(r).get();return((d=y==null?void 0:y.data)==null?void 0:d[0])??null}const u=await this.client.collection(t).doc(e[this.idField]).get();return((a=u==null?void 0:u.data)==null?void 0:a[0])??null}const n=h.QueryBuilder.buildCloudBaseQuery(e,this.fieldMetaMap[t]);if(r){const u=await this.client.collection(t).where(n).field(r).get();return((f=u==null?void 0:u.data)==null?void 0:f[0])??null}const i=await this.client.collection(t).where(n).get();return((w=i==null?void 0:i.data)==null?void 0:w[0])??null}async findUniqueOrThrow(t,{where:e,select:r}){const c=await this.findUnique(t,{where:e,select:r});if(!c)throw new Error("Data Not Found");return c}async findFirst(t,e){const{data:r}=await this.findManyInner(t,{where:e==null?void 0:e.where,orderBy:e==null?void 0:e.orderBy,select:e==null?void 0:e.select,limit:1,offset:0});return(r==null?void 0:r[0])??null}async findFirstOrThrow(t,e){const r=await this.findFirst(t,e);if(!r)throw new Error("Data Not Found");return r}getFindQuery(t,e){const r=h.QueryBuilder.buildCloudBaseQuery((e==null?void 0:e.where)??{},this.fieldMetaMap[t]),c=h.QueryBuilder.getOrderByArray(e==null?void 0:e.orderBy);let n;return e!=null&&e.select?n=this.client.collection(t).where(r).field(e==null?void 0:e.select).skip((e==null?void 0:e.offset)??0):n=this.client.collection(t).where(r).skip((e==null?void 0:e.offset)??0),(e==null?void 0:e.limit)!=null&&(n=n.limit(e.limit)),c.length>0&&c.forEach(i=>{n=n.orderBy(i.fieldName,i.order)}),n}async findManyInner(t,e){return await this.getFindQuery(t,e).get()}async findMany(t,e){const r=e==null?void 0:e.where,c=e==null?void 0:e.orderBy,n=e==null?void 0:e.select,{data:i}=await this.findManyInner(t,{where:r,orderBy:c,select:n,limit:1e3,offset:0});return i}async findPage(t,e){const c=(e==null?void 0:e.limit)||10;if(c>1e3)throw new Error("limit must be less than or equal to 1000");const n=e==null?void 0:e.where,i=e==null?void 0:e.orderBy,d=(e==null?void 0:e.page)||1,a=e==null?void 0:e.select,f=(d-1)*c,w=this.findManyInner(t,{where:n,orderBy:i,select:a,limit:c,offset:f}),u=this.count(t,{where:n}),{data:y}=await w,B=await u,M=Math.ceil(B/c);return{data:y,total:B,page:d,pageCount:M,limit:c,hasPrev:d>1,hasNext:d<M}}async create(t,{data:e}){const r=h.applyDefaultValues(e,this.schemaMeta[t],this.context),c=await this.client.collection(t).add(r);return{_id:(c==null?void 0:c.id)??(c==null?void 0:c[this.idField])}}async update(t,{where:e,data:r}){const c=h.applyUpdateValues(r,this.schemaMeta[t]),n=Object.keys(e??{});if(n.length===1&&n[0]===this.idField){await this.client.collection(t).doc(e[this.idField]).update(c);return}const i=h.QueryBuilder.buildCloudBaseQuery(e,this.fieldMetaMap[t]);await this.client.collection(t).where(i).update(c)}async delete(t,{where:e}){const r=Object.keys(e??{});if(r.length===1&&r[0]===this.idField)return await this.client.collection(t).doc(e[this.idField]).remove();const c=h.QueryBuilder.buildCloudBaseQuery(e,this.fieldMetaMap[t]);await this.client.collection(t).where(c).remove()}async count(t,e){try{const r=this.getFindQuery(t,{where:e==null?void 0:e.where,offset:0}),{total:c}=await r.count();return c}catch(r){throw console.error("count error:",r),r}}async aggregate(t,e){let r=this.client.collection(t).aggregate();e==null||e.forEach(n=>{Object.entries(n??{}).forEach(([d,a])=>{const f=d.replace(/^\$/,"");r=r[f](a)})});const c=await r.end();return c==null?void 0:c.data}}function F(l,t,e){const r=new C(l,t,e),c={$dbClient:l};return Object.keys(t).forEach(n=>{c[n]={findUnique:i=>r.findUnique(n,i),findUniqueOrThrow:i=>r.findUniqueOrThrow(n,i),findFirst:i=>r.findFirst(n,i),findFirstOrThrow:i=>r.findFirstOrThrow(n,i),findMany:i=>r.findMany(n,i),findPage:i=>r.findPage(n,i),create:i=>r.create(n,i),update:i=>r.update(n,i),delete:i=>r.delete(n,i),count:i=>r.count(n,i),aggregate:i=>r.aggregate(n,i)}}),c.$transaction=async n=>{const i=await l.startTransaction();try{const d=F(i,t,e);d.$transaction=void 0;const a=await n(d);return await i.commit(),a}catch(d){throw await i.rollback(),d}},c}exports.createCloudBaseClient=F;
@@ -0,0 +1 @@
1
+ export { createCloudBaseClient } from './client/cloudbase-index';
@@ -1,31 +1,31 @@
1
1
  var B = Object.defineProperty;
2
2
  var q = (l, t, e) => t in l ? B(l, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : l[t] = e;
3
- var h = (l, t, e) => q(l, typeof t != "symbol" ? t + "" : t, e);
4
- import { Q as s, a as C, b as O } from "./deps/query-builder-h6B2D2BCoQ-33f97qk7e.js";
5
- class k {
3
+ var f = (l, t, e) => q(l, typeof t != "symbol" ? t + "" : t, e);
4
+ import { Q as y, a as g, b as C } from "./deps/query-builder-h6B2D2BCoQ-zzx9xwrhd.js";
5
+ class O {
6
6
  constructor(t, e, r) {
7
- h(this, "client");
8
- h(this, "schemaMeta");
9
- h(this, "context");
10
- h(this, "fieldMetaMap", {});
11
- h(this, "idField", "_id");
7
+ f(this, "client");
8
+ f(this, "schemaMeta");
9
+ f(this, "context");
10
+ f(this, "fieldMetaMap", {});
11
+ f(this, "idField", "_id");
12
12
  this.client = t, this.schemaMeta = e, this.context = r, this.fieldMetaMap = Object.entries(e).reduce((c, [n, i]) => (c[n] = i.columns.reduce((d, a) => (d[a.name] = a, d), {}), c), {});
13
13
  }
14
14
  async findUnique(t, { where: e, select: r }) {
15
- var d, a, y, w;
15
+ var d, a, h, w;
16
16
  const c = Object.keys(e ?? {});
17
17
  if (c.length === 1 && c[0] === this.idField) {
18
18
  if (r) {
19
- const f = await this.client.collection(t).doc(e[this.idField]).field(r).get();
20
- return ((d = f == null ? void 0 : f.data) == null ? void 0 : d[0]) ?? null;
19
+ const s = await this.client.collection(t).doc(e[this.idField]).field(r).get();
20
+ return ((d = s == null ? void 0 : s.data) == null ? void 0 : d[0]) ?? null;
21
21
  }
22
22
  const u = await this.client.collection(t).doc(e[this.idField]).get();
23
23
  return ((a = u == null ? void 0 : u.data) == null ? void 0 : a[0]) ?? null;
24
24
  }
25
- const n = s.buildCloudBaseQuery(e, this.fieldMetaMap[t]);
25
+ const n = y.buildCloudBaseQuery(e, this.fieldMetaMap[t]);
26
26
  if (r) {
27
27
  const u = await this.client.collection(t).where(n).field(r).get();
28
- return ((y = u == null ? void 0 : u.data) == null ? void 0 : y[0]) ?? null;
28
+ return ((h = u == null ? void 0 : u.data) == null ? void 0 : h[0]) ?? null;
29
29
  }
30
30
  const i = await this.client.collection(t).where(n).get();
31
31
  return ((w = i == null ? void 0 : i.data) == null ? void 0 : w[0]) ?? null;
@@ -53,7 +53,7 @@ class k {
53
53
  return r;
54
54
  }
55
55
  getFindQuery(t, e) {
56
- const r = s.buildCloudBaseQuery((e == null ? void 0 : e.where) ?? {}, this.fieldMetaMap[t]), c = s.getOrderByArray(e == null ? void 0 : e.orderBy);
56
+ const r = y.buildCloudBaseQuery((e == null ? void 0 : e.where) ?? {}, this.fieldMetaMap[t]), c = y.getOrderByArray(e == null ? void 0 : e.orderBy);
57
57
  let n;
58
58
  return e != null && e.select ? n = this.client.collection(t).where(r).field(e == null ? void 0 : e.select).skip((e == null ? void 0 : e.offset) ?? 0) : n = this.client.collection(t).where(r).skip((e == null ? void 0 : e.offset) ?? 0), (e == null ? void 0 : e.limit) != null && (n = n.limit(e.limit)), c.length > 0 && c.forEach((i) => {
59
59
  n = n.orderBy(i.fieldName, i.order);
@@ -70,27 +70,27 @@ class k {
70
70
  const c = (e == null ? void 0 : e.limit) || 10;
71
71
  if (c > 1e3)
72
72
  throw new Error("limit must be less than or equal to 1000");
73
- const n = e == null ? void 0 : e.where, i = e == null ? void 0 : e.orderBy, d = (e == null ? void 0 : e.page) || 1, a = e == null ? void 0 : e.select, y = (d - 1) * c, w = this.findManyInner(t, { where: n, orderBy: i, select: a, limit: c, offset: y }), u = this.count(t, { where: n }), { data: f } = await w, F = await u, M = Math.ceil(F / c);
74
- return { data: f, total: F, page: d, pageCount: M, limit: c, hasPrev: d > 1, hasNext: d < M };
73
+ const n = e == null ? void 0 : e.where, i = e == null ? void 0 : e.orderBy, d = (e == null ? void 0 : e.page) || 1, a = e == null ? void 0 : e.select, h = (d - 1) * c, w = this.findManyInner(t, { where: n, orderBy: i, select: a, limit: c, offset: h }), u = this.count(t, { where: n }), { data: s } = await w, F = await u, M = Math.ceil(F / c);
74
+ return { data: s, total: F, page: d, pageCount: M, limit: c, hasPrev: d > 1, hasNext: d < M };
75
75
  }
76
76
  async create(t, { data: e }) {
77
- const r = C(e, this.schemaMeta[t], this.context), c = await this.client.collection(t).add(r);
77
+ const r = g(e, this.schemaMeta[t], this.context), c = await this.client.collection(t).add(r);
78
78
  return { _id: (c == null ? void 0 : c.id) ?? (c == null ? void 0 : c[this.idField]) };
79
79
  }
80
80
  async update(t, { where: e, data: r }) {
81
- const c = O(r, this.schemaMeta[t]), n = Object.keys(e ?? {});
81
+ const c = C(r, this.schemaMeta[t]), n = Object.keys(e ?? {});
82
82
  if (n.length === 1 && n[0] === this.idField) {
83
83
  await this.client.collection(t).doc(e[this.idField]).update(c);
84
84
  return;
85
85
  }
86
- const i = s.buildCloudBaseQuery(e, this.fieldMetaMap[t]);
86
+ const i = y.buildCloudBaseQuery(e, this.fieldMetaMap[t]);
87
87
  await this.client.collection(t).where(i).update(c);
88
88
  }
89
89
  async delete(t, { where: e }) {
90
90
  const r = Object.keys(e ?? {});
91
91
  if (r.length === 1 && r[0] === this.idField)
92
92
  return await this.client.collection(t).doc(e[this.idField]).remove();
93
- const c = s.buildCloudBaseQuery(e, this.fieldMetaMap[t]);
93
+ const c = y.buildCloudBaseQuery(e, this.fieldMetaMap[t]);
94
94
  await this.client.collection(t).where(c).remove();
95
95
  }
96
96
  async count(t, e) {
@@ -101,9 +101,20 @@ class k {
101
101
  throw console.error("count error:", r), r;
102
102
  }
103
103
  }
104
+ async aggregate(t, e) {
105
+ let r = this.client.collection(t).aggregate();
106
+ e == null || e.forEach((n) => {
107
+ Object.entries(n ?? {}).forEach(([d, a]) => {
108
+ const h = d.replace(/^\$/, "");
109
+ r = r[h](a);
110
+ });
111
+ });
112
+ const c = await r.end();
113
+ return c == null ? void 0 : c.data;
114
+ }
104
115
  }
105
- function Q(l, t, e) {
106
- const r = new k(l, t, e), c = {};
116
+ function k(l, t, e) {
117
+ const r = new O(l, t, e), c = { $dbClient: l };
107
118
  return Object.keys(t).forEach((n) => {
108
119
  c[n] = {
109
120
  findUnique: (i) => r.findUnique(n, i),
@@ -115,12 +126,13 @@ function Q(l, t, e) {
115
126
  create: (i) => r.create(n, i),
116
127
  update: (i) => r.update(n, i),
117
128
  delete: (i) => r.delete(n, i),
118
- count: (i) => r.count(n, i)
129
+ count: (i) => r.count(n, i),
130
+ aggregate: (i) => r.aggregate(n, i)
119
131
  };
120
132
  }), c.$transaction = async (n) => {
121
133
  const i = await l.startTransaction();
122
134
  try {
123
- const d = Q(i, t, e);
135
+ const d = k(i, t, e);
124
136
  d.$transaction = void 0;
125
137
  const a = await n(d);
126
138
  return await i.commit(), a;
@@ -130,5 +142,5 @@ function Q(l, t, e) {
130
142
  }, c;
131
143
  }
132
144
  export {
133
- Q as createCloudBaseClient
145
+ k as createCloudBaseClient
134
146
  };