@event-driven-io/pongo 0.3.0 → 0.4.0
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.
- package/README.md +8 -2
- package/dist/index.cjs +11 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +90 -62
- package/dist/index.d.ts +90 -62
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/package.json +8 -4
package/README.md
CHANGED
|
@@ -104,8 +104,14 @@ Pongo uses the following table structure for storing collections:
|
|
|
104
104
|
|
|
105
105
|
```sql
|
|
106
106
|
CREATE TABLE IF NOT EXISTS "YourCollectionName" (
|
|
107
|
-
_id
|
|
108
|
-
data
|
|
107
|
+
_id TEXT PRIMARY KEY,
|
|
108
|
+
data JSONB NOT NULL,
|
|
109
|
+
metadata JSONB NOT NULL DEFAULT '{}',
|
|
110
|
+
_version BIGINT NOT NULL DEFAULT 1,
|
|
111
|
+
_partition TEXT NOT NULL DEFAULT 'png_global',
|
|
112
|
+
_archived BOOLEAN NOT NULL DEFAULT FALSE,
|
|
113
|
+
_created TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
114
|
+
_updated TIMESTAMPTZ NOT NULL DEFAULT now()
|
|
109
115
|
)
|
|
110
116
|
```
|
|
111
117
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } async function _asyncOptionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;var _dumbo = require('@event-driven-io/dumbo');require('pg');var _pgformat = require('pg-format'); var _pgformat2 = _interopRequireDefault(_pgformat);var _uuid = require('uuid');var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } async function _asyncOptionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;var _dumbo = require('@event-driven-io/dumbo');require('pg');var _pgformat = require('pg-format'); var _pgformat2 = _interopRequireDefault(_pgformat);var _uuid = require('uuid');var T=t=>Object.entries(t).map(([e,n])=>[e,n]);var D={$eq:"$eq",$gt:"$gt",$gte:"$gte",$lt:"$lt",$lte:"$lte",$ne:"$ne",$in:"$in",$nin:"$nin",$elemMatch:"$elemMatch",$all:"$all",$size:"$size"},F={$gt:">",$gte:">=",$lt:"<",$lte:"<=",$ne:"!="},M= exports.isOperator =t=>t.startsWith("$"),E= exports.hasOperators =t=>Object.keys(t).some(M),O= exports.handleOperator =(t,e,n)=>{if(t==="_id")return $(e,n);switch(e){case"$eq":return _pgformat2.default.call(void 0, "(data @> %L::jsonb OR jsonb_path_exists(data, '$.%s[*] ? (@ == %s)'))",JSON.stringify(x(t,n)),t,JSON.stringify(n));case"$gt":case"$gte":case"$lt":case"$lte":case"$ne":return _pgformat2.default.call(void 0, `data #>> %L ${F[e]} %L`,`{${t.split(".").join(",")}}`,n);case"$in":return _pgformat2.default.call(void 0, "data #>> %L IN (%s)",`{${t.split(".").join(",")}}`,n.map(o=>_pgformat2.default.call(void 0, "%L",o)).join(", "));case"$nin":return _pgformat2.default.call(void 0, "data #>> %L NOT IN (%s)",`{${t.split(".").join(",")}}`,n.map(o=>_pgformat2.default.call(void 0, "%L",o)).join(", "));case"$elemMatch":{let o=T(n).map(([r,d])=>_pgformat2.default.call(void 0, '@."%s" == %s',r,JSON.stringify(d))).join(" && ");return _pgformat2.default.call(void 0, "jsonb_path_exists(data, '$.%s[*] ? (%s)')",t,o)}case"$all":return _pgformat2.default.call(void 0, "data @> %L::jsonb",JSON.stringify(x(t,n)));case"$size":return _pgformat2.default.call(void 0, "jsonb_array_length(data #> %L) = %L",`{${t.split(".").join(",")}}`,n);default:throw new Error(`Unsupported operator: ${e}`)}},$=(t,e)=>{switch(t){case"$eq":return _pgformat2.default.call(void 0, "_id = %L",e);case"$gt":case"$gte":case"$lt":case"$lte":case"$ne":return _pgformat2.default.call(void 0, `_id ${F[t]} %L`,e);case"$in":return _pgformat2.default.call(void 0, "_id IN (%s)",e.map(n=>_pgformat2.default.call(void 0, "%L",n)).join(", "));case"$nin":return _pgformat2.default.call(void 0, "_id NOT IN (%s)",e.map(n=>_pgformat2.default.call(void 0, "%L",n)).join(", "));default:throw new Error(`Unsupported operator: ${t}`)}},x=(t,e)=>t.split(".").reverse().reduce((n,o)=>({[o]:n}),e);var b="AND",c= exports.constructFilterQuery =t=>Object.entries(t).map(([e,n])=>W(n)?A(e,n):O(e,"$eq",n)).join(` ${b} `),A=(t,e)=>{let n=!E(e);return T(e).map(([o,r])=>n?O(`${t}.${o}`,D.$eq,r):O(t,o,r)).join(` ${b} `)},W=t=>t!==null&&typeof t=="object"&&!Array.isArray(t);var h=t=>T(t).reduce((e,[n,o])=>{switch(n){case"$set":return U(o,e);case"$unset":return N(o,e);case"$inc":return Q(o,e);case"$push":return j(o,e);default:return e}},_dumbo.sql.call(void 0, "data")),U= exports.buildSetQuery =(t,e)=>_dumbo.sql.call(void 0, "%s || %L::jsonb",e,JSON.stringify(t)),N= exports.buildUnsetQuery =(t,e)=>_dumbo.sql.call(void 0, "%s - %L",e,Object.keys(t).map(n=>`{${n}}`).join(", ")),Q= exports.buildIncQuery =(t,e)=>{for(let[n,o]of Object.entries(t))e=_dumbo.sql.call(void 0, "jsonb_set(%s, '{%s}', to_jsonb((data->>'%s')::numeric + %L), true)",e,n,n,o);return e},j= exports.buildPushQuery =(t,e)=>{for(let[n,o]of Object.entries(t))e=_dumbo.sql.call(void 0, "jsonb_set(%s, '{%s}', (coalesce(data->'%s', '[]'::jsonb) || %L::jsonb), true)",e,n,n,JSON.stringify([o]));return e};var k=(t,{dbName:e,poolOrClient:n})=>{let o=i=>_dumbo.executeSQL.call(void 0, n,i),r=K(t),d=o(r.createCollection()),u={dbName:e,collectionName:t,createCollection:async()=>{await d},insertOne:async i=>{await d;let s=_uuid.v4.call(void 0, );return(await o(r.insertOne({_id:s,...i}))).rowCount?{insertedId:s,acknowledged:!0}:{insertedId:null,acknowledged:!1}},insertMany:async i=>{await d;let s=i.map(m=>({_id:_uuid.v4.call(void 0, ),...m})),a=await o(r.insertMany(s));return{acknowledged:a.rowCount===s.length,insertedCount:_nullishCoalesce(a.rowCount, () => (0)),insertedIds:s.map(m=>m._id)}},updateOne:async(i,s)=>{await d;let a=await o(r.updateOne(i,s));return a.rowCount?{acknowledged:!0,modifiedCount:a.rowCount}:{acknowledged:!1,modifiedCount:0}},replaceOne:async(i,s)=>{await d;let a=await o(r.replaceOne(i,s));return a.rowCount?{acknowledged:!0,modifiedCount:a.rowCount}:{acknowledged:!1,modifiedCount:0}},updateMany:async(i,s)=>{await d;let a=await o(r.updateMany(i,s));return a.rowCount?{acknowledged:!0,modifiedCount:a.rowCount}:{acknowledged:!1,modifiedCount:0}},deleteOne:async i=>{await d;let s=await o(r.deleteOne(_nullishCoalesce(i, () => ({}))));return s.rowCount?{acknowledged:!0,deletedCount:s.rowCount}:{acknowledged:!1,deletedCount:0}},deleteMany:async i=>{await d;let s=await o(r.deleteMany(_nullishCoalesce(i, () => ({}))));return s.rowCount?{acknowledged:!0,deletedCount:s.rowCount}:{acknowledged:!1,deletedCount:0}},findOne:async i=>(await d,await _asyncNullishCoalesce(await _asyncOptionalChain([(await o(r.findOne(_nullishCoalesce(i, () => ({}))))), 'access', async _2 => _2.rows, 'access', async _3 => _3[0], 'optionalAccess', async _4 => _4.data]), async () => (null))),findOneAndDelete:async i=>{await d;let s=await u.findOne(i);return s===null?null:(await u.deleteOne(i),s)},findOneAndReplace:async(i,s)=>{await d;let a=await u.findOne(i);return a===null?null:(await u.replaceOne(i,s),a)},findOneAndUpdate:async(i,s)=>{await d;let a=await u.findOne(i);return a===null?null:(await u.updateOne(i,s),a)},handle:async(i,s)=>{await d;let a={_id:i},m=await u.findOne(a),f=await s(m);if(!m&&f){let y={...f,_id:i};return await u.insertOne({...y,_id:i}),y}return m&&!f?(await u.deleteOne(a),null):(m&&f&&await u.replaceOne(a,f),f)},find:async i=>(await d,(await o(r.find(_nullishCoalesce(i, () => ({}))))).rows.map(a=>a.data)),countDocuments:async i=>{await d;let{count:s}=await _dumbo.single.call(void 0, o(r.countDocuments(_nullishCoalesce(i, () => ({})))));return s},drop:async()=>(await d,(await _asyncNullishCoalesce(await _asyncOptionalChain([(await o(r.drop())), 'optionalAccess', async _5 => _5.rowCount]), async () => (0)))>0),rename:async i=>(await d,await o(r.rename(i)),t=i,u)};return u},K= exports.collectionSQLBuilder =t=>({createCollection:()=>_dumbo.sql.call(void 0, `CREATE TABLE IF NOT EXISTS %I (
|
|
2
|
+
_id TEXT PRIMARY KEY,
|
|
3
|
+
data JSONB NOT NULL,
|
|
4
|
+
metadata JSONB NOT NULL DEFAULT '{}',
|
|
5
|
+
_version BIGINT NOT NULL DEFAULT 1,
|
|
6
|
+
_partition TEXT NOT NULL DEFAULT 'png_global',
|
|
7
|
+
_archived BOOLEAN NOT NULL DEFAULT FALSE,
|
|
8
|
+
_created TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
9
|
+
_updated TIMESTAMPTZ NOT NULL DEFAULT now()
|
|
10
|
+
)`,t),insertOne:e=>_dumbo.sql.call(void 0, "INSERT INTO %I (_id, data) VALUES (%L, %L)",t,e._id,JSON.stringify(e)),insertMany:e=>{let n=e.map(o=>_pgformat2.default.call(void 0, "(%L, %L)",o._id,JSON.stringify(o))).join(", ");return _dumbo.sql.call(void 0, "INSERT INTO %I (_id, data) VALUES %s",t,n)},updateOne:(e,n)=>{let o=c(e),r=h(n);return _dumbo.sql.call(void 0, `WITH cte AS (
|
|
2
11
|
SELECT _id FROM %I WHERE %s LIMIT 1
|
|
3
12
|
)
|
|
4
|
-
UPDATE %I SET data = %s FROM cte WHERE %I._id = cte._id`,t,o,t,
|
|
13
|
+
UPDATE %I SET data = %s FROM cte WHERE %I._id = cte._id`,t,o,t,r,t)},replaceOne:(e,n)=>{let o=c(e);return _dumbo.sql.call(void 0, "UPDATE %I SET data = %L || jsonb_build_object('_id', data->>'_id') WHERE %s",t,JSON.stringify(n),o)},updateMany:(e,n)=>{let o=c(e),r=h(n);return _dumbo.sql.call(void 0, "UPDATE %I SET data = %s WHERE %s",t,r,o)},deleteOne:e=>{let n=c(e);return _dumbo.sql.call(void 0, "DELETE FROM %I WHERE %s",t,n)},deleteMany:e=>{let n=c(e);return _dumbo.sql.call(void 0, "DELETE FROM %I WHERE %s",t,n)},findOne:e=>{let n=c(e);return _dumbo.sql.call(void 0, "SELECT data FROM %I WHERE %s LIMIT 1",t,n)},find:e=>{let n=c(e);return _dumbo.sql.call(void 0, "SELECT data FROM %I WHERE %s",t,n)},countDocuments:e=>{let n=c(e);return _dumbo.sql.call(void 0, "SELECT COUNT(1) as count FROM %I WHERE %s",t,n)},rename:e=>_dumbo.sql.call(void 0, "ALTER TABLE %I RENAME TO %I",t,e),drop:(e=t)=>_dumbo.sql.call(void 0, "DROP TABLE IF EXISTS %I",e)});var L=t=>{let{connectionString:e,dbName:n,client:o}=t,r=!o,d=_nullishCoalesce(o, () => (_dumbo.getPool.call(void 0, {connectionString:e,database:n})));return{connect:()=>Promise.resolve(),close:()=>r?_dumbo.endPool.call(void 0, {connectionString:e,database:n}):Promise.resolve(),collection:u=>k(u,{dbName:_nullishCoalesce(n, () => (_dumbo.getDatabaseNameOrDefault.call(void 0, e))),poolOrClient:d})}};var C=t=>L(t);var R=t=>{let e=_dumbo.getDatabaseNameOrDefault.call(void 0, t),n=new Map,o=C({connectionString:t});n.set(e,o);let r={connect:async()=>(await o.connect(),r),close:async()=>{for(let d of n.values())await d.close()},db:d=>d?_nullishCoalesce(n.get(d), () => (n.set(d,C({connectionString:t,dbName:d})).get(d))):o};return r};var P= (_class =class{__init() {this.documents=null}__init2() {this.index=0}constructor(e){;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);this.findDocumentsPromise=e}async toArray(){return this.findDocuments()}async forEach(e){let n=await this.findDocuments();for(let o of n)e(o);return Promise.resolve()}hasNext(){if(this.documents===null)throw Error("Error while fetching documents");return this.index<this.documents.length}async next(){let e=await this.findDocuments();return this.hasNext()?_nullishCoalesce(e[this.index++], () => (null)):null}async findDocuments(){return this.documents=await this.findDocumentsPromise,this.documents}}, _class);require('mongodb');var w=class{constructor(e){this.collection=e}get dbName(){return this.collection.dbName}get collectionName(){return this.collection.collectionName}get namespace(){return`${this.dbName}.${this.collectionName}`}get readConcern(){}get readPreference(){}get bsonOptions(){return{}}get writeConcern(){}get hint(){}set hint(e){throw new Error("Method not implemented.")}async insertOne(e,n){let o=await this.collection.insertOne(e);return{acknowledged:o.acknowledged,insertedId:o.insertedId}}async insertMany(e,n){let o=await this.collection.insertMany(e);return{acknowledged:o.acknowledged,insertedIds:o.insertedIds,insertedCount:o.insertedCount}}bulkWrite(e,n){throw new Error("Method not implemented.")}async updateOne(e,n,o){let r=await this.collection.updateOne(e,n);return{acknowledged:r.acknowledged,matchedCount:r.modifiedCount,modifiedCount:r.modifiedCount,upsertedCount:r.modifiedCount,upsertedId:null}}replaceOne(e,n,o){return this.collection.replaceOne(e,n)}async updateMany(e,n,o){let r=await this.collection.updateMany(e,n);return{acknowledged:r.acknowledged,matchedCount:r.modifiedCount,modifiedCount:r.modifiedCount,upsertedCount:r.modifiedCount,upsertedId:null}}async deleteOne(e,n){let o=await this.collection.deleteOne(e);return{acknowledged:o.acknowledged,deletedCount:o.deletedCount}}async deleteMany(e,n){let o=await this.collection.deleteMany(e);return{acknowledged:o.acknowledged,deletedCount:o.deletedCount}}async rename(e,n){return await this.collection.rename(e),this}drop(e){return this.collection.drop()}async findOne(e,n){return this.collection.findOne(e)}find(e,n){return new P(this.collection.find(e))}options(e){throw new Error("Method not implemented.")}isCapped(e){throw new Error("Method not implemented.")}createIndex(e,n){throw new Error("Method not implemented.")}createIndexes(e,n){throw new Error("Method not implemented.")}dropIndex(e,n){throw new Error("Method not implemented.")}dropIndexes(e){throw new Error("Method not implemented.")}listIndexes(e){throw new Error("Method not implemented.")}indexExists(e,n){throw new Error("Method not implemented.")}indexInformation(e){throw new Error("Method not implemented.")}estimatedDocumentCount(e){return this.collection.countDocuments()}countDocuments(e,n){return this.collection.countDocuments(e)}distinct(e,n,o){throw new Error("Method not implemented.")}indexes(e){throw new Error("Method not implemented.")}findOneAndDelete(e,n){return this.collection.findOneAndDelete(e)}findOneAndReplace(e,n,o){return this.collection.findOneAndReplace(e,n)}findOneAndUpdate(e,n,o){return this.collection.findOneAndUpdate(e,n)}aggregate(e,n){throw new Error("Method not implemented.")}watch(e,n){throw new Error("Method not implemented.")}initializeUnorderedBulkOp(e){throw new Error("Method not implemented.")}initializeOrderedBulkOp(e){throw new Error("Method not implemented.")}count(e,n){return this.collection.countDocuments(_nullishCoalesce(e, () => ({})))}listSearchIndexes(e,n){throw new Error("Method not implemented.")}createSearchIndex(e){throw new Error("Method not implemented.")}createSearchIndexes(e){throw new Error("Method not implemented.")}dropSearchIndex(e){throw new Error("Method not implemented.")}updateSearchIndex(e,n){throw new Error("Method not implemented.")}async createCollection(){await this.collection.createCollection()}async handle(e,n){return this.collection.handle(e.toString(),n)}};var I=class{constructor(e){this.pongoDb=e}collection(e){return new w(this.pongoDb.collection(e))}};var _=class{constructor(e){this.pongoClient=R(e)}async connect(){return await this.pongoClient.connect(),this}async close(){await this.pongoClient.close()}db(e){return new I(this.pongoClient.db(e))}};exports.Collection = w; exports.Db = I; exports.FindCursor = P; exports.MongoClient = _; exports.Operators = D; exports.buildIncQuery = Q; exports.buildPushQuery = j; exports.buildSetQuery = U; exports.buildUnsetQuery = N; exports.buildUpdateQuery = h; exports.collectionSQLBuilder = K; exports.constructFilterQuery = c; exports.entries = T; exports.getDbClient = C; exports.handleOperator = O; exports.hasOperators = E; exports.isOperator = M; exports.pongoClient = R; exports.postgresClient = L; exports.postgresCollection = k;
|
|
5
14
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/postgres/client.ts","../src/postgres/postgresCollection.ts","../src/main/typing/entries.ts","../src/postgres/filter/queryOperators.ts","../src/postgres/filter/index.ts","../src/postgres/update/index.ts","../src/main/dbClient.ts","../src/main/client.ts","../src/mongo/findCursor.ts","../src/mongo/mongoDb.ts","../src/mongo/mongoCollection.ts","../src/mongo/mongoClient.ts"],"names":["endPool","getPool","executeSQL","sql","format","uuid","entries","obj","key","value","Operators","OperatorMap","isOperator","hasOperators","handleOperator","path","operator","handleIdOperator","buildNestedObject","v","subQuery","subKey","subValue","acc","AND","constructFilterQuery","filter","isRecord","constructComplexFilterQuery","isEquality","nestedKey","val","buildUpdateQuery","update","currentUpdateQuery","op","buildSetQuery","buildUnsetQuery","buildIncQuery","buildPushQuery","set","unset","k","inc","push","postgresCollection","collectionName","pool","execute","SqlFor","collectionSQLBuilder","createCollection","document","_id","documents","rows","doc","result","d","row","values","filterQuery","updateQuery","postgresClient","connectionString","database","name","getDbClient","pongoClient","dbClient","dbName","FindCursor","callback","docs","Collection","collection","_options","_operations","_filter","_","_newName","_indexSpec","_indexSpecs","_indexName","_indexes","_key","_replacement","_update","_pipeline","_name","_description","_descriptions","_definition","Db","pongoDb","MongoClient"],"mappings":"AAAA,OAAS,WAAAA,EAAS,WAAAC,MAAe,yBCAjC,OAAS,cAAAC,EAAY,OAAAC,MAAqB,yBAC1C,MAAe,KACf,OAAOC,MAAY,YACnB,OAAS,MAAMC,MAAY,OCKpB,IAAMC,EAA6BC,GACxC,OAAO,QAAQA,CAAG,EAAE,IAAI,CAAC,CAACC,EAAKC,CAAK,IAAM,CAACD,EAAgBC,CAAK,CAAC,ECTnE,OAAOL,MAAY,YAGZ,IAAMM,EAAY,CACvB,IAAK,MACL,IAAK,MACL,KAAM,OACN,IAAK,MACL,KAAM,OACN,IAAK,MACL,IAAK,MACL,KAAM,OACN,WAAY,aACZ,KAAM,OACN,MAAO,OACT,EAEMC,EAAc,CAClB,IAAK,IACL,KAAM,KACN,IAAK,IACL,KAAM,KACN,IAAK,IACP,EAEaC,EAAcJ,GAAgBA,EAAI,WAAW,GAAG,EAEhDK,EAAgBJ,GAC3B,OAAO,KAAKA,CAAK,EAAE,KAAKG,CAAU,EAEvBE,EAAiB,CAC5BC,EACAC,EACAP,IACW,CACX,GAAIM,IAAS,MACX,OAAOE,EAAiBD,EAAUP,CAAK,EAGzC,OAAQO,EAAU,CAChB,IAAK,MACH,OAAOZ,EACL,wEACA,KAAK,UAAUc,EAAkBH,EAAMN,CAAK,CAAC,EAC7CM,EACA,KAAK,UAAUN,CAAK,CACtB,EACF,IAAK,MACL,IAAK,OACL,IAAK,MACL,IAAK,OACL,IAAK,MACH,OAAOL,EACL,eAAeO,EAAYK,CAAQ,CAAC,MACpC,IAAID,EAAK,MAAM,GAAG,EAAE,KAAK,GAAG,CAAC,IAC7BN,CACF,EACF,IAAK,MACH,OAAO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AER,YAAY/B,EAA0B,CACpC,KAAK,YAAcI,EAAYJ,CAAgB,CACjD,CAEA,MAAM,SAAU,CACd,aAAM,KAAK,YAAY,QAAQ,EACxB,IACT,CAEA,MAAM,OAAQ,CACZ,MAAM,KAAK,YAAY,MAAM,CAC/B,CAEA,GAAGM,EAAqB,CACtB,OAAO,IAAIuB,EAAG,KAAK,YAAY,GAAGvB,CAAM,CAAC,CAC3C,CACF","sourcesContent":["import { endPool, getPool } from '@event-driven-io/dumbo';\nimport { type DbClient } from '../main';\nimport { postgresCollection } from './postgresCollection';\n\nexport const postgresClient = (\n connectionString: string,\n database?: string,\n): DbClient => {\n const pool = getPool({ connectionString, database });\n\n return {\n connect: () => Promise.resolve(),\n close: () => endPool(connectionString),\n collection: <T>(name: string) => postgresCollection<T>(name, pool),\n };\n};\n","import { executeSQL, sql, type SQL } from '@event-driven-io/dumbo';\nimport pg from 'pg';\nimport format from 'pg-format';\nimport { v4 as uuid } from 'uuid';\nimport {\n type PongoCollection,\n type PongoDeleteResult,\n type PongoFilter,\n type PongoInsertManyResult,\n type PongoInsertOneResult,\n type PongoUpdate,\n type PongoUpdateResult,\n type WithId,\n} from '../main';\nimport { constructFilterQuery } from './filter';\nimport { buildUpdateQuery } from './update';\n\nexport const postgresCollection = <T>(\n collectionName: string,\n pool: pg.Pool,\n): PongoCollection<T> => {\n const execute = (sql: SQL) => executeSQL(pool, sql);\n const SqlFor = collectionSQLBuilder(collectionName);\n\n const createCollection = execute(SqlFor.createCollection());\n\n return {\n createCollection: async () => {\n await createCollection;\n },\n insertOne: async (document: T): Promise<PongoInsertOneResult> => {\n await createCollection;\n\n const _id = uuid();\n\n const result = await execute(SqlFor.insertOne({ _id, ...document }));\n\n return result.rowCount\n ? { insertedId: _id, acknowledged: true }\n : { insertedId: null, acknowledged: false };\n },\n insertMany: async (documents: T[]): Promise<PongoInsertManyResult> => {\n await createCollection;\n\n const rows = documents.map((doc) => ({\n _id: uuid(),\n ...doc,\n }));\n\n const result = await execute(SqlFor.insertMany(rows));\n\n return {\n acknowledged: result.rowCount === rows.length,\n insertedCount: result.rowCount ?? 0,\n insertedIds: rows.map((d) => d._id),\n };\n },\n updateOne: async (\n filter: PongoFilter<T>,\n update: PongoUpdate<T>,\n ): Promise<PongoUpdateResult> => {\n await createCollection;\n\n const result = await execute(SqlFor.updateOne(filter, update));\n return result.rowCount\n ? { acknowledged: true, modifiedCount: result.rowCount }\n : { acknowledged: false, modifiedCount: 0 };\n },\n updateMany: async (\n filter: PongoFilter<T>,\n update: PongoUpdate<T>,\n ): Promise<PongoUpdateResult> => {\n await createCollection;\n\n const result = await execute(SqlFor.updateMany(filter, update));\n return result.rowCount\n ? { acknowledged: true, modifiedCount: result.rowCount }\n : { acknowledged: false, modifiedCount: 0 };\n },\n deleteOne: async (filter: PongoFilter<T>): Promise<PongoDeleteResult> => {\n await createCollection;\n\n const result = await execute(SqlFor.deleteOne(filter));\n return result.rowCount\n ? { acknowledged: true, deletedCount: result.rowCount }\n : { acknowledged: false, deletedCount: 0 };\n },\n deleteMany: async (filter: PongoFilter<T>): Promise<PongoDeleteResult> => {\n await createCollection;\n\n const result = await execute(SqlFor.deleteMany(filter));\n return result.rowCount\n ? { acknowledged: true, deletedCount: result.rowCount }\n : { acknowledged: false, deletedCount: 0 };\n },\n findOne: async (filter: PongoFilter<T>): Promise<T | null> => {\n await createCollection;\n\n const result = await execute(SqlFor.findOne(filter));\n return (result.rows[0]?.data ?? null) as T | null;\n },\n find: async (filter: PongoFilter<T>): Promise<T[]> => {\n await createCollection;\n\n const result = await execute(SqlFor.find(filter));\n return result.rows.map((row) => row.data as T);\n },\n };\n};\n\nexport const collectionSQLBuilder = (collectionName: string) => ({\n createCollection: (): SQL =>\n sql(\n 'CREATE TABLE IF NOT EXISTS %I (_id UUID PRIMARY KEY, data JSONB)',\n collectionName,\n ),\n insertOne: <T>(document: WithId<T>): SQL =>\n sql(\n 'INSERT INTO %I (_id, data) VALUES (%L, %L)',\n collectionName,\n document._id,\n JSON.stringify(document),\n ),\n insertMany: <T>(documents: WithId<T>[]): SQL => {\n const values = documents\n .map((doc) => format('(%L, %L)', doc._id, JSON.stringify(doc)))\n .join(', ');\n return sql('INSERT INTO %I (_id, data) VALUES %s', collectionName, values);\n },\n updateOne: <T>(filter: PongoFilter<T>, update: PongoUpdate<T>): SQL => {\n const filterQuery = constructFilterQuery(filter);\n const updateQuery = buildUpdateQuery(update);\n\n return sql(\n `WITH cte AS (\n SELECT _id FROM %I WHERE %s LIMIT 1\n )\n UPDATE %I SET data = %s FROM cte WHERE %I._id = cte._id`,\n collectionName,\n filterQuery,\n collectionName,\n updateQuery,\n collectionName,\n );\n },\n updateMany: <T>(filter: PongoFilter<T>, update: PongoUpdate<T>): SQL => {\n const filterQuery = constructFilterQuery(filter);\n const updateQuery = buildUpdateQuery(update);\n\n return sql(\n 'UPDATE %I SET data = %s WHERE %s',\n collectionName,\n updateQuery,\n filterQuery,\n );\n },\n deleteOne: <T>(filter: PongoFilter<T>): SQL => {\n const filterQuery = constructFilterQuery(filter);\n return sql('DELETE FROM %I WHERE %s', collectionName, filterQuery);\n },\n deleteMany: <T>(filter: PongoFilter<T>): SQL => {\n const filterQuery = constructFilterQuery(filter);\n return sql('DELETE FROM %I WHERE %s', collectionName, filterQuery);\n },\n findOne: <T>(filter: PongoFilter<T>): SQL => {\n const filterQuery = constructFilterQuery(filter);\n return sql(\n 'SELECT data FROM %I WHERE %s LIMIT 1',\n collectionName,\n filterQuery,\n );\n },\n find: <T>(filter: PongoFilter<T>): SQL => {\n const filterQuery = constructFilterQuery(filter);\n return sql('SELECT data FROM %I WHERE %s', collectionName, filterQuery);\n },\n});\n","type Entry<T> = {\n [K in keyof Required<T>]: [K, Required<T>[K]];\n}[keyof Required<T>];\n\ntype IterableEntry<T> = Entry<T> & {\n [Symbol.iterator](): Iterator<Entry<T>>;\n};\n\nexport const entries = <T extends object>(obj: T): IterableEntry<T>[] =>\n Object.entries(obj).map(([key, value]) => [key as keyof T, value]);\n\nexport type NonPartial<T> = { [K in keyof Required<T>]: T[K] };\n","import format from 'pg-format';\nimport { entries } from '../../main/typing';\n\nexport const Operators = {\n $eq: '$eq',\n $gt: '$gt',\n $gte: '$gte',\n $lt: '$lt',\n $lte: '$lte',\n $ne: '$ne',\n $in: '$in',\n $nin: '$nin',\n $elemMatch: '$elemMatch',\n $all: '$all',\n $size: '$size',\n};\n\nconst OperatorMap = {\n $gt: '>',\n $gte: '>=',\n $lt: '<',\n $lte: '<=',\n $ne: '!=',\n};\n\nexport const isOperator = (key: string) => key.startsWith('$');\n\nexport const hasOperators = (value: Record<string, unknown>) =>\n Object.keys(value).some(isOperator);\n\nexport const handleOperator = (\n path: string,\n operator: string,\n value: unknown,\n): string => {\n if (path === '_id') {\n return handleIdOperator(operator, value);\n }\n\n switch (operator) {\n case '$eq':\n return format(\n `(data @> %L::jsonb OR jsonb_path_exists(data, '$.%s[*] ? (@ == %s)'))`,\n JSON.stringify(buildNestedObject(path, value)),\n path,\n JSON.stringify(value),\n );\n case '$gt':\n case '$gte':\n case '$lt':\n case '$lte':\n case '$ne':\n return format(\n `data #>> %L ${OperatorMap[operator]} %L`,\n `{${path.split('.').join(',')}}`,\n value,\n );\n case '$in':\n return format(\n 'data #>> %L IN (%s)',\n `{${path.split('.').join(',')}}`,\n (value as unknown[]).map((v) => format('%L', v)).join(', '),\n );\n case '$nin':\n return format(\n 'data #>> %L NOT IN (%s)',\n `{${path.split('.').join(',')}}`,\n (value as unknown[]).map((v) => format('%L', v)).join(', '),\n );\n case '$elemMatch': {\n const subQuery = entries(value as Record<string, unknown>)\n .map(([subKey, subValue]) =>\n format(`@.\"%s\" == %s`, subKey, JSON.stringify(subValue)),\n )\n .join(' && ');\n return format(\n `jsonb_path_exists(data, '$.%s[*] ? (%s)')`,\n path,\n subQuery,\n );\n }\n case '$all':\n return format(\n 'data @> %L::jsonb',\n JSON.stringify(buildNestedObject(path, value)),\n );\n case '$size':\n return format(\n 'jsonb_array_length(data #> %L) = %L',\n `{${path.split('.').join(',')}}`,\n value,\n );\n default:\n throw new Error(`Unsupported operator: ${operator}`);\n }\n};\n\nconst handleIdOperator = (operator: string, value: unknown): string => {\n switch (operator) {\n case '$eq':\n return format(`_id = %L`, value);\n case '$gt':\n case '$gte':\n case '$lt':\n case '$lte':\n case '$ne':\n return format(`_id ${OperatorMap[operator]} %L`, value);\n case '$in':\n return format(\n `_id IN (%s)`,\n (value as unknown[]).map((v) => format('%L', v)).join(', '),\n );\n case '$nin':\n return format(\n `_id NOT IN (%s)`,\n (value as unknown[]).map((v) => format('%L', v)).join(', '),\n );\n default:\n throw new Error(`Unsupported operator: ${operator}`);\n }\n};\n\nconst buildNestedObject = (\n path: string,\n value: unknown,\n): Record<string, unknown> =>\n path\n .split('.')\n .reverse()\n .reduce((acc, key) => ({ [key]: acc }), value as Record<string, unknown>);\n","import type { PongoFilter } from '../../main';\nimport { entries } from '../../main/typing';\nimport { Operators, handleOperator, hasOperators } from './queryOperators';\n\nexport * from './queryOperators';\n\nconst AND = 'AND';\n\nexport const constructFilterQuery = <T>(filter: PongoFilter<T>): string =>\n Object.entries(filter)\n .map(([key, value]) =>\n isRecord(value)\n ? constructComplexFilterQuery(key, value)\n : handleOperator(key, '$eq', value),\n )\n .join(` ${AND} `);\n\nconst constructComplexFilterQuery = (\n key: string,\n value: Record<string, unknown>,\n): string => {\n const isEquality = !hasOperators(value);\n\n return entries(value)\n .map(\n ([nestedKey, val]) =>\n isEquality\n ? handleOperator(`${key}.${nestedKey}`, Operators.$eq, val) // regular value\n : handleOperator(key, nestedKey, val), // operator\n )\n .join(` ${AND} `);\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n value !== null && typeof value === 'object' && !Array.isArray(value);\n","import { sql, type SQL } from '@event-driven-io/dumbo';\nimport type { $inc, $push, $set, $unset, PongoUpdate } from '../../main';\nimport { entries } from '../../main/typing';\n\nexport const buildUpdateQuery = <T>(update: PongoUpdate<T>): SQL =>\n entries(update).reduce((currentUpdateQuery, [op, value]) => {\n switch (op) {\n case '$set':\n return buildSetQuery(value, currentUpdateQuery);\n case '$unset':\n return buildUnsetQuery(value, currentUpdateQuery);\n case '$inc':\n return buildIncQuery(value, currentUpdateQuery);\n case '$push':\n return buildPushQuery(value, currentUpdateQuery);\n default:\n return currentUpdateQuery;\n }\n }, sql('data'));\n\nexport const buildSetQuery = <T>(set: $set<T>, currentUpdateQuery: SQL): SQL =>\n sql('%s || %L::jsonb', currentUpdateQuery, JSON.stringify(set));\n\nexport const buildUnsetQuery = <T>(\n unset: $unset<T>,\n currentUpdateQuery: SQL,\n): SQL =>\n sql(\n '%s - %L',\n currentUpdateQuery,\n Object.keys(unset)\n .map((k) => `{${k}}`)\n .join(', '),\n );\n\nexport const buildIncQuery = <T>(\n inc: $inc<T>,\n currentUpdateQuery: SQL,\n): SQL => {\n for (const [key, value] of Object.entries(inc)) {\n currentUpdateQuery = sql(\n \"jsonb_set(%s, '{%s}', to_jsonb((data->>'%s')::numeric + %L), true)\",\n currentUpdateQuery,\n key,\n key,\n value,\n );\n }\n return currentUpdateQuery;\n};\n\nexport const buildPushQuery = <T>(\n push: $push<T>,\n currentUpdateQuery: SQL,\n): SQL => {\n for (const [key, value] of Object.entries(push)) {\n currentUpdateQuery = sql(\n \"jsonb_set(%s, '{%s}', (coalesce(data->'%s', '[]'::jsonb) || %L::jsonb), true)\",\n currentUpdateQuery,\n key,\n key,\n JSON.stringify([value]),\n );\n }\n return currentUpdateQuery;\n};\n","import { postgresClient } from '../postgres';\nimport type { PongoCollection } from './typing/operations';\n\nexport interface DbClient {\n connect(): Promise<void>;\n close(): Promise<void>;\n collection: <T>(name: string) => PongoCollection<T>;\n}\n\nexport const getDbClient = (\n connectionString: string,\n database?: string,\n): DbClient => {\n // This is the place where in the future could come resolution of other database types\n return postgresClient(connectionString, database);\n};\n","import { getDbClient } from './dbClient';\nimport type { PongoClient, PongoDb } from './typing/operations';\n\nexport const pongoClient = (connectionString: string): PongoClient => {\n const dbClient = getDbClient(connectionString);\n\n const pongoClient: PongoClient = {\n connect: async () => {\n await dbClient.connect();\n return pongoClient;\n },\n close: () => dbClient.close(),\n db: (dbName?: string): PongoDb =>\n dbName ? getDbClient(connectionString, dbName) : dbClient,\n };\n\n return pongoClient;\n};\n","export class FindCursor<T> {\n private findDocumentsPromise: Promise<T[]>;\n private documents: T[] | null = null;\n private index: number = 0;\n\n constructor(documents: Promise<T[]>) {\n this.findDocumentsPromise = documents;\n }\n\n async toArray(): Promise<T[]> {\n return this.findDocuments();\n }\n\n async forEach(callback: (doc: T) => void): Promise<void> {\n const docs = await this.findDocuments();\n\n for (const doc of docs) {\n callback(doc);\n }\n return Promise.resolve();\n }\n\n hasNext(): boolean {\n if (this.documents === null) throw Error('Error while fetching documents');\n return this.index < this.documents.length;\n }\n\n async next(): Promise<T | null> {\n const docs = await this.findDocuments();\n return this.hasNext() ? docs[this.index++] ?? null : null;\n }\n\n private async findDocuments(): Promise<T[]> {\n this.documents = await this.findDocumentsPromise;\n return this.documents;\n }\n}\n","import { Collection as MongoCollection, type Document } from 'mongodb';\nimport type { PongoDb } from '../main';\nimport { Collection } from './mongoCollection';\n\nexport class Db {\n constructor(private pongoDb: PongoDb) {}\n\n collection<T extends Document>(collectionName: string): MongoCollection<T> {\n return new Collection<T>(this.pongoDb.collection<T>(collectionName));\n }\n}\n","import type {\n AbstractCursorOptions,\n AggregateOptions,\n AggregationCursor,\n AnyBulkWriteOperation,\n BSONSerializeOptions,\n BulkWriteOptions,\n BulkWriteResult,\n ChangeStream,\n ChangeStreamDocument,\n ChangeStreamOptions,\n CommandOperationOptions,\n CountDocumentsOptions,\n CountOptions,\n CreateIndexesOptions,\n DeleteOptions,\n DeleteResult,\n Document,\n DropCollectionOptions,\n EnhancedOmit,\n EstimatedDocumentCountOptions,\n Filter,\n FindOneAndDeleteOptions,\n FindOneAndReplaceOptions,\n FindOneAndUpdateOptions,\n FindOptions,\n Flatten,\n Hint,\n IndexDescription,\n IndexDescriptionCompact,\n IndexDescriptionInfo,\n IndexInformationOptions,\n IndexSpecification,\n InferIdType,\n InsertManyResult,\n InsertOneOptions,\n InsertOneResult,\n ListIndexesCursor,\n ListSearchIndexesCursor,\n ListSearchIndexesOptions,\n ModifyResult,\n Collection as MongoCollection,\n FindCursor as MongoFindCursor,\n OperationOptions,\n OptionalUnlessRequiredId,\n OrderedBulkOperation,\n ReadConcern,\n ReadPreference,\n RenameOptions,\n ReplaceOptions,\n SearchIndexDescription,\n UnorderedBulkOperation,\n UpdateFilter,\n UpdateOptions,\n UpdateResult,\n WithId,\n WithoutId,\n WriteConcern,\n} from 'mongodb';\nimport type { Key } from 'readline';\nimport type { PongoCollection, PongoFilter, PongoUpdate } from '../main';\nimport { FindCursor } from './findCursor';\n\nexport class Collection<T extends Document> implements MongoCollection<T> {\n private collection: PongoCollection<T>;\n\n constructor(collection: PongoCollection<T>) {\n this.collection = collection;\n }\n get dbName(): string {\n throw new Error('Method not implemented.');\n }\n get collectionName(): string {\n throw new Error('Method not implemented.');\n }\n get namespace(): string {\n throw new Error('Method not implemented.');\n }\n get readConcern(): ReadConcern | undefined {\n throw new Error('Method not implemented.');\n }\n get readPreference(): ReadPreference | undefined {\n throw new Error('Method not implemented.');\n }\n get bsonOptions(): BSONSerializeOptions {\n throw new Error('Method not implemented.');\n }\n get writeConcern(): WriteConcern | undefined {\n throw new Error('Method not implemented.');\n }\n get hint(): Hint | undefined {\n throw new Error('Method not implemented.');\n }\n set hint(v: Hint | undefined) {\n throw new Error('Method not implemented.');\n }\n async insertOne(\n doc: OptionalUnlessRequiredId<T>,\n _options?: InsertOneOptions | undefined,\n ): Promise<InsertOneResult<T>> {\n const result = await this.collection.insertOne(doc as T);\n return {\n acknowledged: result.acknowledged,\n insertedId: result.insertedId as unknown as InferIdType<T>,\n };\n }\n async insertMany(\n docs: OptionalUnlessRequiredId<T>[],\n _options?: BulkWriteOptions | undefined,\n ): Promise<InsertManyResult<T>> {\n const result = await this.collection.insertMany(docs as T[]);\n return {\n acknowledged: result.acknowledged,\n insertedIds: result.insertedIds as unknown as InferIdType<T>[],\n insertedCount: result.insertedCount,\n };\n }\n bulkWrite(\n _operations: AnyBulkWriteOperation<T>[],\n _options?: BulkWriteOptions | undefined,\n ): Promise<BulkWriteResult> {\n throw new Error('Method not implemented.');\n }\n async updateOne(\n filter: Filter<T>,\n update: Document[] | UpdateFilter<T>,\n _options?: UpdateOptions | undefined,\n ): Promise<UpdateResult<T>> {\n const result = await this.collection.updateOne(\n filter as unknown as PongoFilter<T>,\n update as unknown as PongoUpdate<T>,\n );\n\n return {\n acknowledged: result.acknowledged,\n matchedCount: result.modifiedCount,\n modifiedCount: result.modifiedCount,\n upsertedCount: result.modifiedCount,\n upsertedId: null,\n };\n }\n replaceOne(\n _filter: Filter<T>,\n _: WithoutId<T>,\n _options?: ReplaceOptions | undefined,\n ): Promise<Document | UpdateResult<T>> {\n throw new Error('Method not implemented.');\n }\n async updateMany(\n filter: Filter<T>,\n update: Document[] | UpdateFilter<T>,\n _options?: UpdateOptions | undefined,\n ): Promise<UpdateResult<T>> {\n const result = await this.collection.updateMany(\n filter as unknown as PongoFilter<T>,\n update as unknown as PongoUpdate<T>,\n );\n\n return {\n acknowledged: result.acknowledged,\n matchedCount: result.modifiedCount,\n modifiedCount: result.modifiedCount,\n upsertedCount: result.modifiedCount,\n upsertedId: null,\n };\n }\n async deleteOne(\n filter?: Filter<T> | undefined,\n _options?: DeleteOptions | undefined,\n ): Promise<DeleteResult> {\n const result = await this.collection.deleteOne(\n filter as unknown as PongoFilter<T>,\n );\n\n return {\n acknowledged: result.acknowledged,\n deletedCount: result.deletedCount,\n };\n }\n async deleteMany(\n filter?: Filter<T> | undefined,\n _options?: DeleteOptions | undefined,\n ): Promise<DeleteResult> {\n const result = await this.collection.deleteMany(\n filter as unknown as PongoFilter<T>,\n );\n\n return {\n acknowledged: result.acknowledged,\n deletedCount: result.deletedCount,\n };\n }\n rename(\n _newName: string,\n _options?: RenameOptions | undefined,\n ): Promise<Collection<Document>> {\n throw new Error('Method not implemented.');\n }\n drop(_options?: DropCollectionOptions | undefined): Promise<boolean> {\n throw new Error('Method not implemented.');\n }\n findOne(): Promise<WithId<T> | null>;\n findOne(filter: Filter<T>): Promise<WithId<T> | null>;\n findOne(\n filter: Filter<T>,\n options: FindOptions<Document>,\n ): Promise<WithId<T> | null>;\n findOne<TS = T>(): Promise<TS | null>;\n findOne<TS = T>(filter: Filter<TS>): Promise<TS | null>;\n findOne<TS = T>(\n filter: Filter<TS>,\n options?: FindOptions<Document> | undefined,\n ): Promise<TS | null>;\n async findOne(\n filter?: unknown,\n _options?: unknown,\n ): Promise<import('mongodb').WithId<T> | T | null> {\n return this.collection.findOne(filter as PongoFilter<T>);\n }\n find(): MongoFindCursor<WithId<T>>;\n find(\n filter: Filter<T>,\n options?: FindOptions<Document> | undefined,\n ): MongoFindCursor<WithId<T>>;\n find<T extends Document>(\n filter: Filter<T>,\n options?: FindOptions<Document> | undefined,\n ): MongoFindCursor<T>;\n find(\n filter?: unknown,\n _options?: unknown,\n ): MongoFindCursor<WithId<T>> | MongoFindCursor<T> {\n return new FindCursor(\n this.collection.find(filter as PongoFilter<T>),\n ) as unknown as MongoFindCursor<T>;\n }\n options(_options?: OperationOptions | undefined): Promise<Document> {\n throw new Error('Method not implemented.');\n }\n isCapped(_options?: OperationOptions | undefined): Promise<boolean> {\n throw new Error('Method not implemented.');\n }\n createIndex(\n _indexSpec: IndexSpecification,\n _options?: CreateIndexesOptions | undefined,\n ): Promise<string> {\n throw new Error('Method not implemented.');\n }\n createIndexes(\n _indexSpecs: IndexDescription[],\n _options?: CreateIndexesOptions | undefined,\n ): Promise<string[]> {\n throw new Error('Method not implemented.');\n }\n dropIndex(\n _indexName: string,\n _options?: CommandOperationOptions | undefined,\n ): Promise<Document> {\n throw new Error('Method not implemented.');\n }\n dropIndexes(\n _options?: CommandOperationOptions | undefined,\n ): Promise<boolean> {\n throw new Error('Method not implemented.');\n }\n listIndexes(_options?: AbstractCursorOptions | undefined): ListIndexesCursor {\n throw new Error('Method not implemented.');\n }\n indexExists(\n _indexes: string | string[],\n _options?: AbstractCursorOptions | undefined,\n ): Promise<boolean> {\n throw new Error('Method not implemented.');\n }\n indexInformation(\n options: IndexInformationOptions & { full: true },\n ): Promise<IndexDescriptionInfo[]>;\n indexInformation(\n options: IndexInformationOptions & { full?: false | undefined },\n ): Promise<IndexDescriptionCompact>;\n indexInformation(\n options: IndexInformationOptions,\n ): Promise<IndexDescriptionCompact | IndexDescriptionInfo[]>;\n indexInformation(): Promise<IndexDescriptionCompact>;\n indexInformation(\n _options?: unknown,\n ):\n | Promise<import('mongodb').IndexDescriptionInfo[]>\n | Promise<import('mongodb').IndexDescriptionCompact>\n | Promise<\n | import('mongodb').IndexDescriptionCompact\n | import('mongodb').IndexDescriptionInfo[]\n > {\n throw new Error('Method not implemented.');\n }\n estimatedDocumentCount(\n _options?: EstimatedDocumentCountOptions | undefined,\n ): Promise<number> {\n throw new Error('Method not implemented.');\n }\n countDocuments(\n _filter?: Filter<T> | undefined,\n _options?: CountDocumentsOptions | undefined,\n ): Promise<number> {\n throw new Error('Method not implemented.');\n }\n distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(\n key: Key,\n ): Promise<Flatten<WithId<T>[Key]>[]>;\n distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(\n key: Key,\n filter: Filter<T>,\n ): Promise<Flatten<WithId<T>[Key]>[]>;\n distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(\n key: Key,\n filter: Filter<T>,\n options: CommandOperationOptions,\n ): Promise<Flatten<WithId<T>[Key]>[]>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n distinct(key: string): Promise<any[]>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n distinct(key: string, filter: Filter<T>): Promise<any[]>;\n distinct(\n key: string,\n filter: Filter<T>,\n options: CommandOperationOptions, // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): Promise<any[]>;\n distinct(\n _key: unknown,\n _filter?: unknown,\n _options?: unknown,\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Promise<any[]>\n | Promise<import('mongodb').Flatten<import('mongodb').WithId<T>[Key]>[]> {\n throw new Error('Method not implemented.');\n }\n indexes(\n options: IndexInformationOptions & { full?: true | undefined },\n ): Promise<IndexDescriptionInfo[]>;\n indexes(\n options: IndexInformationOptions & { full: false },\n ): Promise<IndexDescriptionCompact>;\n indexes(\n options: IndexInformationOptions,\n ): Promise<IndexDescriptionCompact | IndexDescriptionInfo[]>;\n indexes(\n options?: AbstractCursorOptions | undefined,\n ): Promise<IndexDescriptionInfo[]>;\n indexes(\n _options?: unknown,\n ):\n | Promise<import('mongodb').IndexDescriptionInfo[]>\n | Promise<import('mongodb').IndexDescriptionCompact>\n | Promise<\n | import('mongodb').IndexDescriptionCompact\n | import('mongodb').IndexDescriptionInfo[]\n > {\n throw new Error('Method not implemented.');\n }\n findOneAndDelete(\n filter: Filter<T>,\n options: FindOneAndDeleteOptions & { includeResultMetadata: true },\n ): Promise<ModifyResult<T>>;\n findOneAndDelete(\n filter: Filter<T>,\n options: FindOneAndDeleteOptions & { includeResultMetadata: false },\n ): Promise<WithId<T> | null>;\n findOneAndDelete(\n filter: Filter<T>,\n options: FindOneAndDeleteOptions,\n ): Promise<WithId<T> | null>;\n findOneAndDelete(filter: Filter<T>): Promise<WithId<T> | null>;\n findOneAndDelete(\n _filter: unknown,\n _options?: unknown,\n ):\n | Promise<import('mongodb').WithId<T> | null>\n | Promise<import('mongodb').ModifyResult<T>> {\n throw new Error('Method not implemented.');\n }\n findOneAndReplace(\n filter: Filter<T>,\n replacement: WithoutId<T>,\n options: FindOneAndReplaceOptions & { includeResultMetadata: true },\n ): Promise<ModifyResult<T>>;\n findOneAndReplace(\n filter: Filter<T>,\n replacement: WithoutId<T>,\n options: FindOneAndReplaceOptions & { includeResultMetadata: false },\n ): Promise<WithId<T> | null>;\n findOneAndReplace(\n filter: Filter<T>,\n replacement: WithoutId<T>,\n options: FindOneAndReplaceOptions,\n ): Promise<WithId<T> | null>;\n findOneAndReplace(\n filter: Filter<T>,\n replacement: WithoutId<T>,\n ): Promise<WithId<T> | null>;\n findOneAndReplace(\n _filter: unknown,\n _replacement: unknown,\n _options?: unknown,\n ):\n | Promise<import('mongodb').WithId<T> | null>\n | Promise<import('mongodb').ModifyResult<T>> {\n throw new Error('Method not implemented.');\n }\n findOneAndUpdate(\n filter: Filter<T>,\n update: UpdateFilter<T>,\n options: FindOneAndUpdateOptions & { includeResultMetadata: true },\n ): Promise<ModifyResult<T>>;\n findOneAndUpdate(\n filter: Filter<T>,\n update: UpdateFilter<T>,\n options: FindOneAndUpdateOptions & { includeResultMetadata: false },\n ): Promise<WithId<T> | null>;\n findOneAndUpdate(\n filter: Filter<T>,\n update: UpdateFilter<T>,\n options: FindOneAndUpdateOptions,\n ): Promise<WithId<T> | null>;\n findOneAndUpdate(\n filter: Filter<T>,\n update: UpdateFilter<T>,\n ): Promise<WithId<T> | null>;\n findOneAndUpdate(\n _filter: unknown,\n _update: unknown,\n _options?: unknown,\n ):\n | Promise<import('mongodb').WithId<T> | null>\n | Promise<import('mongodb').ModifyResult<T>> {\n throw new Error('Method not implemented.');\n }\n aggregate<T extends Document = Document>(\n _pipeline?: Document[] | undefined,\n _options?: AggregateOptions | undefined,\n ): AggregationCursor<T> {\n throw new Error('Method not implemented.');\n }\n watch<\n TLocal extends Document = T,\n TChange extends Document = ChangeStreamDocument<TLocal>,\n >(\n _pipeline?: Document[] | undefined,\n _options?: ChangeStreamOptions | undefined,\n ): ChangeStream<TLocal, TChange> {\n throw new Error('Method not implemented.');\n }\n initializeUnorderedBulkOp(\n _options?: BulkWriteOptions | undefined,\n ): UnorderedBulkOperation {\n throw new Error('Method not implemented.');\n }\n initializeOrderedBulkOp(\n _options?: BulkWriteOptions | undefined,\n ): OrderedBulkOperation {\n throw new Error('Method not implemented.');\n }\n count(\n _filter?: Filter<T> | undefined,\n _options?: CountOptions | undefined,\n ): Promise<number> {\n throw new Error('Method not implemented.');\n }\n listSearchIndexes(\n options?: ListSearchIndexesOptions | undefined,\n ): ListSearchIndexesCursor;\n listSearchIndexes(\n name: string,\n options?: ListSearchIndexesOptions | undefined,\n ): ListSearchIndexesCursor;\n listSearchIndexes(\n _name?: unknown,\n _options?: unknown,\n ): import('mongodb').ListSearchIndexesCursor {\n throw new Error('Method not implemented.');\n }\n createSearchIndex(_description: SearchIndexDescription): Promise<string> {\n throw new Error('Method not implemented.');\n }\n createSearchIndexes(\n _descriptions: SearchIndexDescription[],\n ): Promise<string[]> {\n throw new Error('Method not implemented.');\n }\n dropSearchIndex(_name: string): Promise<void> {\n throw new Error('Method not implemented.');\n }\n updateSearchIndex(_name: string, _definition: Document): Promise<void> {\n throw new Error('Method not implemented.');\n }\n\n async createCollection(): Promise<void> {\n await this.collection.createCollection();\n }\n}\n","// src/MongoClientShim.ts\nimport { pongoClient, type PongoClient } from '../main';\nimport { Db } from './mongoDb';\n\nexport class MongoClient {\n private pongoClient: PongoClient;\n\n constructor(connectionString: string) {\n this.pongoClient = pongoClient(connectionString);\n }\n\n async connect() {\n await this.pongoClient.connect();\n return this;\n }\n\n async close() {\n await this.pongoClient.close();\n }\n\n db(dbName?: string): Db {\n return new Db(this.pongoClient.db(dbName));\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/postgres/client.ts","../src/postgres/postgresCollection.ts","../src/main/typing/entries.ts","../src/postgres/filter/queryOperators.ts","../src/postgres/filter/index.ts","../src/postgres/update/index.ts","../src/main/dbClient.ts","../src/main/pongoClient.ts","../src/mongo/findCursor.ts","../src/mongo/mongoDb.ts","../src/mongo/mongoCollection.ts","../src/mongo/mongoClient.ts"],"names":["endPool","getDatabaseNameOrDefault","getPool","executeSQL","single","sql","format","uuid","entries","obj","key","value","Operators","OperatorMap","isOperator","hasOperators","handleOperator","path","operator","handleIdOperator","buildNestedObject","v","subQuery","subKey","subValue","acc","AND","constructFilterQuery","filter","isRecord","constructComplexFilterQuery","isEquality","nestedKey","val","buildUpdateQuery","update","currentUpdateQuery","op","buildSetQuery","buildUnsetQuery","buildIncQuery","buildPushQuery","set","unset","k","inc","push","postgresCollection","collectionName","dbName","clientOrPool","execute","SqlFor","collectionSQLBuilder","createCollection","collection","document","_id","documents","rows","doc","result","d","existingDoc","replacement","id","handle","byId","existing","newDoc","row","count","newName","values","filterQuery","updateQuery","targetName","postgresClient","options","connectionString","client","managesPoolLifetime","poolOrClient","name","getDbClient","pongoClient","defaultDbName","dbClients","dbClient","db","FindCursor","callback","docs","Collection","_options","_operations","_indexSpec","_indexSpecs","_indexName","_indexes","_key","_filter","_pipeline","_name","_description","_descriptions","_definition","Db","pongoDb","MongoClient"],"mappings":"AAAA,OACE,WAAAA,EACA,4BAAAC,EACA,WAAAC,MACK,yBACP,MAAe,KCLf,OAAS,cAAAC,EAAY,UAAAC,EAAQ,OAAAC,MAAqB,yBAClD,MAAe,KACf,OAAOC,MAAY,YACnB,OAAS,MAAMC,MAAY,OCKpB,IAAMC,EAA6BC,GACxC,OAAO,QAAQA,CAAG,EAAE,IAAI,CAAC,CAACC,EAAKC,CAAK,IAAM,CAACD,EAAgBC,CAAK,CAAC,ECTnE,OAAOL,MAAY,YAGZ,IAAMM,EAAY,CACvB,IAAK,MACL,IAAK,MACL,KAAM,OACN,IAAK,MACL,KAAM,OACN,IAAK,MACL,IAAK,MACL,KAAM,OACN,WAAY,aACZ,KAAM,OACN,MAAO,OACT,EAEMC,EAAc,CAClB,IAAK,IACL,KAAM,KACN,IAAK,IACL,KAAM,KACN,IAAK,IACP,EAEaC,EAAcJ,GAAgBA,EAAI,WAAW,GAAG,EAEhDK,EAAgBJ,GAC3B,OAAO,KAAKA,CAAK,EAAE,KAAKG,CAAU,EAEvBE,EAAiB,CAC5BC,EACAC,EACAP,IACW,CACX,GAAIM,IAAS,MACX,OAAOE,EAAiBD,EAAUP,CAAK,EAGzC,OAAQO,EAAU,CAChB,IAAK,MACH,OAAOZ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MAAM,yBAAyB,CAC3C,CACA,kBAAkBA,EAAeG,EAAsC,CACrE,MAAM,IAAI,MAAM,yBAAyB,CAC3C,CAEA,MAAM,kBAAkC,CACtC,MAAM,KAAK,WAAW,iBAAiB,CACzC,CACA,MAAM,OAAOzC,EAAcC,EAA+C,CACxE,OAAO,KAAK,WAAW,OAAOD,EAAG,SAAS,EAAGC,CAAM,CACrD,CACF,EDtfO,IAAMyC,EAAN,KAAS,CACd,YAAoBC,EAAkB,CAAlB,aAAAA,CAAmB,CAEvC,WACE5D,EAGA,CACA,OAAO,IAAI6C,EAAc,KAAK,QAAQ,WAAc7C,CAAc,CAAC,CACrE,CACF,EEdO,IAAM6D,EAAN,KAAkB,CACf,YAER,YAAY9B,EAA0B,CACpC,KAAK,YAAcM,EAAYN,CAAgB,CACjD,CAEA,MAAM,SAAU,CACd,aAAM,KAAK,YAAY,QAAQ,EACxB,IACT,CAEA,MAAM,OAAQ,CACZ,MAAM,KAAK,YAAY,MAAM,CAC/B,CAEA,GAAG9B,EAAqB,CACtB,OAAO,IAAI0D,EAAG,KAAK,YAAY,GAAG1D,CAAM,CAAC,CAC3C,CACF","sourcesContent":["import {\n endPool,\n getDatabaseNameOrDefault,\n getPool,\n} from '@event-driven-io/dumbo';\nimport pg from 'pg';\nimport { type DbClient, type PongoDocument } from '../main';\nimport { postgresCollection } from './postgresCollection';\n\nexport type PongoClientOptions = {\n connectionString: string;\n dbName?: string | undefined;\n client?: pg.PoolClient;\n};\n\nexport const postgresClient = (options: PongoClientOptions): DbClient => {\n const { connectionString, dbName, client } = options;\n const managesPoolLifetime = !client;\n const poolOrClient =\n client ?? getPool({ connectionString, database: dbName });\n\n return {\n connect: () => Promise.resolve(),\n close: () =>\n managesPoolLifetime\n ? endPool({ connectionString, database: dbName })\n : Promise.resolve(),\n collection: <T extends PongoDocument>(name: string) =>\n postgresCollection<T>(name, {\n dbName: dbName ?? getDatabaseNameOrDefault(connectionString),\n poolOrClient,\n }),\n };\n};\n","import { executeSQL, single, sql, type SQL } from '@event-driven-io/dumbo';\nimport pg from 'pg';\nimport format from 'pg-format';\nimport { v4 as uuid } from 'uuid';\nimport {\n type DocumentHandler,\n type PongoCollection,\n type PongoDeleteResult,\n type PongoDocument,\n type PongoFilter,\n type PongoInsertManyResult,\n type PongoInsertOneResult,\n type PongoUpdate,\n type PongoUpdateResult,\n type WithId,\n type WithoutId,\n} from '../main';\nimport { constructFilterQuery } from './filter';\nimport { buildUpdateQuery } from './update';\n\nexport const postgresCollection = <T extends PongoDocument>(\n collectionName: string,\n {\n dbName,\n poolOrClient: clientOrPool,\n }: { dbName: string; poolOrClient: pg.Pool | pg.PoolClient },\n): PongoCollection<T> => {\n const execute = <T extends pg.QueryResultRow = pg.QueryResultRow>(sql: SQL) =>\n executeSQL<T>(clientOrPool, sql);\n const SqlFor = collectionSQLBuilder(collectionName);\n\n const createCollection = execute(SqlFor.createCollection());\n\n const collection = {\n dbName,\n collectionName,\n createCollection: async () => {\n await createCollection;\n },\n insertOne: async (document: T): Promise<PongoInsertOneResult> => {\n await createCollection;\n\n const _id = uuid();\n\n const result = await execute(SqlFor.insertOne({ _id, ...document }));\n\n return result.rowCount\n ? { insertedId: _id, acknowledged: true }\n : { insertedId: null, acknowledged: false };\n },\n insertMany: async (documents: T[]): Promise<PongoInsertManyResult> => {\n await createCollection;\n\n const rows = documents.map((doc) => ({\n _id: uuid(),\n ...doc,\n }));\n\n const result = await execute(SqlFor.insertMany(rows));\n\n return {\n acknowledged: result.rowCount === rows.length,\n insertedCount: result.rowCount ?? 0,\n insertedIds: rows.map((d) => d._id),\n };\n },\n updateOne: async (\n filter: PongoFilter<T>,\n update: PongoUpdate<T>,\n ): Promise<PongoUpdateResult> => {\n await createCollection;\n\n const result = await execute(SqlFor.updateOne(filter, update));\n return result.rowCount\n ? { acknowledged: true, modifiedCount: result.rowCount }\n : { acknowledged: false, modifiedCount: 0 };\n },\n replaceOne: async (\n filter: PongoFilter<T>,\n document: WithoutId<T>,\n ): Promise<PongoUpdateResult> => {\n await createCollection;\n\n const result = await execute(SqlFor.replaceOne(filter, document));\n return result.rowCount\n ? { acknowledged: true, modifiedCount: result.rowCount }\n : { acknowledged: false, modifiedCount: 0 };\n },\n updateMany: async (\n filter: PongoFilter<T>,\n update: PongoUpdate<T>,\n ): Promise<PongoUpdateResult> => {\n await createCollection;\n\n const result = await execute(SqlFor.updateMany(filter, update));\n return result.rowCount\n ? { acknowledged: true, modifiedCount: result.rowCount }\n : { acknowledged: false, modifiedCount: 0 };\n },\n deleteOne: async (filter?: PongoFilter<T>): Promise<PongoDeleteResult> => {\n await createCollection;\n\n const result = await execute(SqlFor.deleteOne(filter ?? {}));\n return result.rowCount\n ? { acknowledged: true, deletedCount: result.rowCount }\n : { acknowledged: false, deletedCount: 0 };\n },\n deleteMany: async (filter?: PongoFilter<T>): Promise<PongoDeleteResult> => {\n await createCollection;\n\n const result = await execute(SqlFor.deleteMany(filter ?? {}));\n return result.rowCount\n ? { acknowledged: true, deletedCount: result.rowCount }\n : { acknowledged: false, deletedCount: 0 };\n },\n findOne: async (filter?: PongoFilter<T>): Promise<T | null> => {\n await createCollection;\n\n const result = await execute(SqlFor.findOne(filter ?? {}));\n return (result.rows[0]?.data ?? null) as T | null;\n },\n findOneAndDelete: async (filter: PongoFilter<T>): Promise<T | null> => {\n await createCollection;\n\n const existingDoc = await collection.findOne(filter);\n\n if (existingDoc === null) return null;\n\n await collection.deleteOne(filter);\n return existingDoc;\n },\n findOneAndReplace: async (\n filter: PongoFilter<T>,\n replacement: WithoutId<T>,\n ): Promise<T | null> => {\n await createCollection;\n\n const existingDoc = await collection.findOne(filter);\n\n if (existingDoc === null) return null;\n\n await collection.replaceOne(filter, replacement);\n\n return existingDoc;\n },\n findOneAndUpdate: async (\n filter: PongoFilter<T>,\n update: PongoUpdate<T>,\n ): Promise<T | null> => {\n await createCollection;\n\n const existingDoc = await collection.findOne(filter);\n\n if (existingDoc === null) return null;\n\n await collection.updateOne(filter, update);\n\n return existingDoc;\n },\n handle: async (\n id: string,\n handle: DocumentHandler<T>,\n ): Promise<T | null> => {\n await createCollection;\n\n const byId: PongoFilter<T> = { _id: id };\n\n const existing = await collection.findOne(byId);\n\n const result = await handle(existing);\n\n if (!existing && result) {\n const newDoc = { ...result, _id: id };\n await collection.insertOne({ ...newDoc, _id: id });\n return newDoc;\n }\n\n if (existing && !result) {\n await collection.deleteOne(byId);\n return null;\n }\n\n if (existing && result) await collection.replaceOne(byId, result);\n\n return result;\n },\n find: async (filter?: PongoFilter<T>): Promise<T[]> => {\n await createCollection;\n\n const result = await execute(SqlFor.find(filter ?? {}));\n return result.rows.map((row) => row.data as T);\n },\n countDocuments: async (filter?: PongoFilter<T>): Promise<number> => {\n await createCollection;\n\n const { count } = await single(\n execute<{ count: number }>(SqlFor.countDocuments(filter ?? {})),\n );\n return count;\n },\n drop: async (): Promise<boolean> => {\n await createCollection;\n const result = await execute(SqlFor.drop());\n return (result?.rowCount ?? 0) > 0;\n },\n rename: async (newName: string): Promise<PongoCollection<T>> => {\n await createCollection;\n await execute(SqlFor.rename(newName));\n collectionName = newName;\n return collection;\n },\n };\n\n return collection;\n};\n\nexport const collectionSQLBuilder = (collectionName: string) => ({\n createCollection: (): SQL =>\n sql(\n `CREATE TABLE IF NOT EXISTS %I (\n _id TEXT PRIMARY KEY, \n data JSONB NOT NULL, \n metadata JSONB NOT NULL DEFAULT '{}',\n _version BIGINT NOT NULL DEFAULT 1,\n _partition TEXT NOT NULL DEFAULT 'png_global',\n _archived BOOLEAN NOT NULL DEFAULT FALSE,\n _created TIMESTAMPTZ NOT NULL DEFAULT now(),\n _updated TIMESTAMPTZ NOT NULL DEFAULT now()\n )`,\n collectionName,\n ),\n insertOne: <T>(document: WithId<T>): SQL =>\n sql(\n 'INSERT INTO %I (_id, data) VALUES (%L, %L)',\n collectionName,\n document._id,\n JSON.stringify(document),\n ),\n insertMany: <T>(documents: WithId<T>[]): SQL => {\n const values = documents\n .map((doc) => format('(%L, %L)', doc._id, JSON.stringify(doc)))\n .join(', ');\n return sql('INSERT INTO %I (_id, data) VALUES %s', collectionName, values);\n },\n updateOne: <T>(filter: PongoFilter<T>, update: PongoUpdate<T>): SQL => {\n const filterQuery = constructFilterQuery(filter);\n const updateQuery = buildUpdateQuery(update);\n\n return sql(\n `WITH cte AS (\n SELECT _id FROM %I WHERE %s LIMIT 1\n )\n UPDATE %I SET data = %s FROM cte WHERE %I._id = cte._id`,\n collectionName,\n filterQuery,\n collectionName,\n updateQuery,\n collectionName,\n );\n },\n replaceOne: <T>(filter: PongoFilter<T>, document: WithoutId<T>): SQL => {\n const filterQuery = constructFilterQuery(filter);\n\n return sql(\n `UPDATE %I SET data = %L || jsonb_build_object('_id', data->>'_id') WHERE %s`,\n collectionName,\n JSON.stringify(document),\n filterQuery,\n );\n },\n updateMany: <T>(filter: PongoFilter<T>, update: PongoUpdate<T>): SQL => {\n const filterQuery = constructFilterQuery(filter);\n const updateQuery = buildUpdateQuery(update);\n\n return sql(\n 'UPDATE %I SET data = %s WHERE %s',\n collectionName,\n updateQuery,\n filterQuery,\n );\n },\n deleteOne: <T>(filter: PongoFilter<T>): SQL => {\n const filterQuery = constructFilterQuery(filter);\n return sql('DELETE FROM %I WHERE %s', collectionName, filterQuery);\n },\n deleteMany: <T>(filter: PongoFilter<T>): SQL => {\n const filterQuery = constructFilterQuery(filter);\n return sql('DELETE FROM %I WHERE %s', collectionName, filterQuery);\n },\n findOne: <T>(filter: PongoFilter<T>): SQL => {\n const filterQuery = constructFilterQuery(filter);\n return sql(\n 'SELECT data FROM %I WHERE %s LIMIT 1',\n collectionName,\n filterQuery,\n );\n },\n find: <T>(filter: PongoFilter<T>): SQL => {\n const filterQuery = constructFilterQuery(filter);\n return sql('SELECT data FROM %I WHERE %s', collectionName, filterQuery);\n },\n countDocuments: <T>(filter: PongoFilter<T>): SQL => {\n const filterQuery = constructFilterQuery(filter);\n return sql(\n 'SELECT COUNT(1) as count FROM %I WHERE %s',\n collectionName,\n filterQuery,\n );\n },\n rename: (newName: string): SQL =>\n sql('ALTER TABLE %I RENAME TO %I', collectionName, newName),\n drop: (targetName: string = collectionName): SQL =>\n sql('DROP TABLE IF EXISTS %I', targetName),\n});\n","type Entry<T> = {\n [K in keyof Required<T>]: [K, Required<T>[K]];\n}[keyof Required<T>];\n\ntype IterableEntry<T> = Entry<T> & {\n [Symbol.iterator](): Iterator<Entry<T>>;\n};\n\nexport const entries = <T extends object>(obj: T): IterableEntry<T>[] =>\n Object.entries(obj).map(([key, value]) => [key as keyof T, value]);\n\nexport type NonPartial<T> = { [K in keyof Required<T>]: T[K] };\n","import format from 'pg-format';\nimport { entries } from '../../main/typing';\n\nexport const Operators = {\n $eq: '$eq',\n $gt: '$gt',\n $gte: '$gte',\n $lt: '$lt',\n $lte: '$lte',\n $ne: '$ne',\n $in: '$in',\n $nin: '$nin',\n $elemMatch: '$elemMatch',\n $all: '$all',\n $size: '$size',\n};\n\nconst OperatorMap = {\n $gt: '>',\n $gte: '>=',\n $lt: '<',\n $lte: '<=',\n $ne: '!=',\n};\n\nexport const isOperator = (key: string) => key.startsWith('$');\n\nexport const hasOperators = (value: Record<string, unknown>) =>\n Object.keys(value).some(isOperator);\n\nexport const handleOperator = (\n path: string,\n operator: string,\n value: unknown,\n): string => {\n if (path === '_id') {\n return handleIdOperator(operator, value);\n }\n\n switch (operator) {\n case '$eq':\n return format(\n `(data @> %L::jsonb OR jsonb_path_exists(data, '$.%s[*] ? (@ == %s)'))`,\n JSON.stringify(buildNestedObject(path, value)),\n path,\n JSON.stringify(value),\n );\n case '$gt':\n case '$gte':\n case '$lt':\n case '$lte':\n case '$ne':\n return format(\n `data #>> %L ${OperatorMap[operator]} %L`,\n `{${path.split('.').join(',')}}`,\n value,\n );\n case '$in':\n return format(\n 'data #>> %L IN (%s)',\n `{${path.split('.').join(',')}}`,\n (value as unknown[]).map((v) => format('%L', v)).join(', '),\n );\n case '$nin':\n return format(\n 'data #>> %L NOT IN (%s)',\n `{${path.split('.').join(',')}}`,\n (value as unknown[]).map((v) => format('%L', v)).join(', '),\n );\n case '$elemMatch': {\n const subQuery = entries(value as Record<string, unknown>)\n .map(([subKey, subValue]) =>\n format(`@.\"%s\" == %s`, subKey, JSON.stringify(subValue)),\n )\n .join(' && ');\n return format(\n `jsonb_path_exists(data, '$.%s[*] ? (%s)')`,\n path,\n subQuery,\n );\n }\n case '$all':\n return format(\n 'data @> %L::jsonb',\n JSON.stringify(buildNestedObject(path, value)),\n );\n case '$size':\n return format(\n 'jsonb_array_length(data #> %L) = %L',\n `{${path.split('.').join(',')}}`,\n value,\n );\n default:\n throw new Error(`Unsupported operator: ${operator}`);\n }\n};\n\nconst handleIdOperator = (operator: string, value: unknown): string => {\n switch (operator) {\n case '$eq':\n return format(`_id = %L`, value);\n case '$gt':\n case '$gte':\n case '$lt':\n case '$lte':\n case '$ne':\n return format(`_id ${OperatorMap[operator]} %L`, value);\n case '$in':\n return format(\n `_id IN (%s)`,\n (value as unknown[]).map((v) => format('%L', v)).join(', '),\n );\n case '$nin':\n return format(\n `_id NOT IN (%s)`,\n (value as unknown[]).map((v) => format('%L', v)).join(', '),\n );\n default:\n throw new Error(`Unsupported operator: ${operator}`);\n }\n};\n\nconst buildNestedObject = (\n path: string,\n value: unknown,\n): Record<string, unknown> =>\n path\n .split('.')\n .reverse()\n .reduce((acc, key) => ({ [key]: acc }), value as Record<string, unknown>);\n","import type { PongoFilter } from '../../main';\nimport { entries } from '../../main/typing';\nimport { Operators, handleOperator, hasOperators } from './queryOperators';\n\nexport * from './queryOperators';\n\nconst AND = 'AND';\n\nexport const constructFilterQuery = <T>(filter: PongoFilter<T>): string =>\n Object.entries(filter)\n .map(([key, value]) =>\n isRecord(value)\n ? constructComplexFilterQuery(key, value)\n : handleOperator(key, '$eq', value),\n )\n .join(` ${AND} `);\n\nconst constructComplexFilterQuery = (\n key: string,\n value: Record<string, unknown>,\n): string => {\n const isEquality = !hasOperators(value);\n\n return entries(value)\n .map(\n ([nestedKey, val]) =>\n isEquality\n ? handleOperator(`${key}.${nestedKey}`, Operators.$eq, val) // regular value\n : handleOperator(key, nestedKey, val), // operator\n )\n .join(` ${AND} `);\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n value !== null && typeof value === 'object' && !Array.isArray(value);\n","import { sql, type SQL } from '@event-driven-io/dumbo';\nimport type { $inc, $push, $set, $unset, PongoUpdate } from '../../main';\nimport { entries } from '../../main/typing';\n\nexport const buildUpdateQuery = <T>(update: PongoUpdate<T>): SQL =>\n entries(update).reduce((currentUpdateQuery, [op, value]) => {\n switch (op) {\n case '$set':\n return buildSetQuery(value, currentUpdateQuery);\n case '$unset':\n return buildUnsetQuery(value, currentUpdateQuery);\n case '$inc':\n return buildIncQuery(value, currentUpdateQuery);\n case '$push':\n return buildPushQuery(value, currentUpdateQuery);\n default:\n return currentUpdateQuery;\n }\n }, sql('data'));\n\nexport const buildSetQuery = <T>(set: $set<T>, currentUpdateQuery: SQL): SQL =>\n sql('%s || %L::jsonb', currentUpdateQuery, JSON.stringify(set));\n\nexport const buildUnsetQuery = <T>(\n unset: $unset<T>,\n currentUpdateQuery: SQL,\n): SQL =>\n sql(\n '%s - %L',\n currentUpdateQuery,\n Object.keys(unset)\n .map((k) => `{${k}}`)\n .join(', '),\n );\n\nexport const buildIncQuery = <T>(\n inc: $inc<T>,\n currentUpdateQuery: SQL,\n): SQL => {\n for (const [key, value] of Object.entries(inc)) {\n currentUpdateQuery = sql(\n \"jsonb_set(%s, '{%s}', to_jsonb((data->>'%s')::numeric + %L), true)\",\n currentUpdateQuery,\n key,\n key,\n value,\n );\n }\n return currentUpdateQuery;\n};\n\nexport const buildPushQuery = <T>(\n push: $push<T>,\n currentUpdateQuery: SQL,\n): SQL => {\n for (const [key, value] of Object.entries(push)) {\n currentUpdateQuery = sql(\n \"jsonb_set(%s, '{%s}', (coalesce(data->'%s', '[]'::jsonb) || %L::jsonb), true)\",\n currentUpdateQuery,\n key,\n key,\n JSON.stringify([value]),\n );\n }\n return currentUpdateQuery;\n};\n","import { postgresClient, type PongoClientOptions } from '../postgres';\nimport type { PongoCollection, PongoDocument } from './typing/operations';\n\nexport interface DbClient {\n connect(): Promise<void>;\n close(): Promise<void>;\n collection: <T extends PongoDocument>(name: string) => PongoCollection<T>;\n}\n\nexport const getDbClient = (options: PongoClientOptions): DbClient => {\n // This is the place where in the future could come resolution of other database types\n return postgresClient(options);\n};\n","import { getDatabaseNameOrDefault } from '@event-driven-io/dumbo';\nimport { getDbClient, type DbClient } from './dbClient';\nimport type { PongoClient, PongoDb } from './typing/operations';\n\nexport const pongoClient = (connectionString: string): PongoClient => {\n const defaultDbName = getDatabaseNameOrDefault(connectionString);\n const dbClients: Map<string, DbClient> = new Map();\n\n const dbClient = getDbClient({ connectionString });\n dbClients.set(defaultDbName, dbClient);\n\n const pongoClient: PongoClient = {\n connect: async () => {\n await dbClient.connect();\n return pongoClient;\n },\n close: async () => {\n for (const db of dbClients.values()) {\n await db.close();\n }\n },\n db: (dbName?: string): PongoDb => {\n if (!dbName) return dbClient;\n\n return (\n dbClients.get(dbName) ??\n dbClients\n .set(dbName, getDbClient({ connectionString, dbName: dbName }))\n .get(dbName)!\n );\n },\n };\n\n return pongoClient;\n};\n","export class FindCursor<T> {\n private findDocumentsPromise: Promise<T[]>;\n private documents: T[] | null = null;\n private index: number = 0;\n\n constructor(documents: Promise<T[]>) {\n this.findDocumentsPromise = documents;\n }\n\n async toArray(): Promise<T[]> {\n return this.findDocuments();\n }\n\n async forEach(callback: (doc: T) => void): Promise<void> {\n const docs = await this.findDocuments();\n\n for (const doc of docs) {\n callback(doc);\n }\n return Promise.resolve();\n }\n\n hasNext(): boolean {\n if (this.documents === null) throw Error('Error while fetching documents');\n return this.index < this.documents.length;\n }\n\n async next(): Promise<T | null> {\n const docs = await this.findDocuments();\n return this.hasNext() ? docs[this.index++] ?? null : null;\n }\n\n private async findDocuments(): Promise<T[]> {\n this.documents = await this.findDocumentsPromise;\n return this.documents;\n }\n}\n","import {\n Collection as MongoCollection,\n ObjectId,\n type Document,\n} from 'mongodb';\nimport type { DocumentHandler, PongoDb } from '../main';\nimport { Collection } from './mongoCollection';\n\nexport class Db {\n constructor(private pongoDb: PongoDb) {}\n\n collection<T extends Document>(\n collectionName: string,\n ): MongoCollection<T> & {\n handle(id: ObjectId, handle: DocumentHandler<T>): Promise<T | null>;\n } {\n return new Collection<T>(this.pongoDb.collection<T>(collectionName));\n }\n}\n","import type {\n AbstractCursorOptions,\n AggregateOptions,\n AggregationCursor,\n AnyBulkWriteOperation,\n BSONSerializeOptions,\n BulkWriteOptions,\n BulkWriteResult,\n ChangeStream,\n ChangeStreamDocument,\n ChangeStreamOptions,\n CommandOperationOptions,\n CountDocumentsOptions,\n CountOptions,\n CreateIndexesOptions,\n DeleteOptions,\n DeleteResult,\n Document,\n DropCollectionOptions,\n EnhancedOmit,\n EstimatedDocumentCountOptions,\n Filter,\n FindOneAndDeleteOptions,\n FindOneAndReplaceOptions,\n FindOneAndUpdateOptions,\n FindOptions,\n Flatten,\n Hint,\n IndexDescription,\n IndexDescriptionCompact,\n IndexDescriptionInfo,\n IndexInformationOptions,\n IndexSpecification,\n InferIdType,\n InsertManyResult,\n InsertOneOptions,\n InsertOneResult,\n ListIndexesCursor,\n ListSearchIndexesCursor,\n ListSearchIndexesOptions,\n ModifyResult,\n Collection as MongoCollection,\n FindCursor as MongoFindCursor,\n ObjectId,\n OperationOptions,\n OptionalUnlessRequiredId,\n OrderedBulkOperation,\n ReadConcern,\n ReadPreference,\n RenameOptions,\n ReplaceOptions,\n SearchIndexDescription,\n UnorderedBulkOperation,\n UpdateFilter,\n UpdateOptions,\n UpdateResult,\n WithId,\n WithoutId,\n WriteConcern,\n} from 'mongodb';\nimport type { Key } from 'readline';\nimport type {\n DocumentHandler,\n PongoCollection,\n PongoFilter,\n PongoUpdate,\n} from '../main';\nimport { FindCursor } from './findCursor';\n\nexport class Collection<T extends Document> implements MongoCollection<T> {\n private collection: PongoCollection<T>;\n\n constructor(collection: PongoCollection<T>) {\n this.collection = collection;\n }\n get dbName(): string {\n return this.collection.dbName;\n }\n get collectionName(): string {\n return this.collection.collectionName;\n }\n get namespace(): string {\n return `${this.dbName}.${this.collectionName}`;\n }\n get readConcern(): ReadConcern | undefined {\n return undefined;\n }\n get readPreference(): ReadPreference | undefined {\n return undefined;\n }\n get bsonOptions(): BSONSerializeOptions {\n return {};\n }\n get writeConcern(): WriteConcern | undefined {\n return undefined;\n }\n get hint(): Hint | undefined {\n return undefined;\n }\n set hint(v: Hint | undefined) {\n throw new Error('Method not implemented.');\n }\n async insertOne(\n doc: OptionalUnlessRequiredId<T>,\n _options?: InsertOneOptions | undefined,\n ): Promise<InsertOneResult<T>> {\n const result = await this.collection.insertOne(doc as T);\n return {\n acknowledged: result.acknowledged,\n insertedId: result.insertedId as unknown as InferIdType<T>,\n };\n }\n async insertMany(\n docs: OptionalUnlessRequiredId<T>[],\n _options?: BulkWriteOptions | undefined,\n ): Promise<InsertManyResult<T>> {\n const result = await this.collection.insertMany(docs as T[]);\n return {\n acknowledged: result.acknowledged,\n insertedIds: result.insertedIds as unknown as InferIdType<T>[],\n insertedCount: result.insertedCount,\n };\n }\n bulkWrite(\n _operations: AnyBulkWriteOperation<T>[],\n _options?: BulkWriteOptions | undefined,\n ): Promise<BulkWriteResult> {\n throw new Error('Method not implemented.');\n }\n async updateOne(\n filter: Filter<T>,\n update: Document[] | UpdateFilter<T>,\n _options?: UpdateOptions | undefined,\n ): Promise<UpdateResult<T>> {\n const result = await this.collection.updateOne(\n filter as unknown as PongoFilter<T>,\n update as unknown as PongoUpdate<T>,\n );\n\n return {\n acknowledged: result.acknowledged,\n matchedCount: result.modifiedCount,\n modifiedCount: result.modifiedCount,\n upsertedCount: result.modifiedCount,\n upsertedId: null,\n };\n }\n replaceOne(\n filter: Filter<T>,\n document: WithoutId<T>,\n _options?: ReplaceOptions | undefined,\n ): Promise<Document | UpdateResult<T>> {\n return this.collection.replaceOne(\n filter as unknown as PongoFilter<T>,\n document,\n );\n }\n async updateMany(\n filter: Filter<T>,\n update: Document[] | UpdateFilter<T>,\n _options?: UpdateOptions | undefined,\n ): Promise<UpdateResult<T>> {\n const result = await this.collection.updateMany(\n filter as unknown as PongoFilter<T>,\n update as unknown as PongoUpdate<T>,\n );\n\n return {\n acknowledged: result.acknowledged,\n matchedCount: result.modifiedCount,\n modifiedCount: result.modifiedCount,\n upsertedCount: result.modifiedCount,\n upsertedId: null,\n };\n }\n async deleteOne(\n filter?: Filter<T> | undefined,\n _options?: DeleteOptions | undefined,\n ): Promise<DeleteResult> {\n const result = await this.collection.deleteOne(filter as PongoFilter<T>);\n\n return {\n acknowledged: result.acknowledged,\n deletedCount: result.deletedCount,\n };\n }\n async deleteMany(\n filter?: Filter<T> | undefined,\n _options?: DeleteOptions | undefined,\n ): Promise<DeleteResult> {\n const result = await this.collection.deleteMany(filter as PongoFilter<T>);\n\n return {\n acknowledged: result.acknowledged,\n deletedCount: result.deletedCount,\n };\n }\n async rename(\n newName: string,\n _options?: RenameOptions | undefined,\n ): Promise<Collection<Document>> {\n await this.collection.rename(newName);\n\n return this as unknown as Collection<Document>;\n }\n drop(_options?: DropCollectionOptions | undefined): Promise<boolean> {\n return this.collection.drop();\n }\n findOne(): Promise<WithId<T> | null>;\n findOne(filter: Filter<T>): Promise<WithId<T> | null>;\n findOne(\n filter: Filter<T>,\n options: FindOptions<Document>,\n ): Promise<WithId<T> | null>;\n findOne<TS = T>(): Promise<TS | null>;\n findOne<TS = T>(filter: Filter<TS>): Promise<TS | null>;\n findOne<TS = T>(\n filter: Filter<TS>,\n options?: FindOptions<Document> | undefined,\n ): Promise<TS | null>;\n async findOne(\n filter?: unknown,\n _options?: unknown,\n ): Promise<import('mongodb').WithId<T> | T | null> {\n return this.collection.findOne(filter as PongoFilter<T>);\n }\n find(): MongoFindCursor<WithId<T>>;\n find(\n filter: Filter<T>,\n options?: FindOptions<Document> | undefined,\n ): MongoFindCursor<WithId<T>>;\n find<T extends Document>(\n filter: Filter<T>,\n options?: FindOptions<Document> | undefined,\n ): MongoFindCursor<T>;\n find(\n filter?: unknown,\n _options?: unknown,\n ): MongoFindCursor<WithId<T>> | MongoFindCursor<T> {\n return new FindCursor(\n this.collection.find(filter as PongoFilter<T>),\n ) as unknown as MongoFindCursor<T>;\n }\n options(_options?: OperationOptions | undefined): Promise<Document> {\n throw new Error('Method not implemented.');\n }\n isCapped(_options?: OperationOptions | undefined): Promise<boolean> {\n throw new Error('Method not implemented.');\n }\n createIndex(\n _indexSpec: IndexSpecification,\n _options?: CreateIndexesOptions | undefined,\n ): Promise<string> {\n throw new Error('Method not implemented.');\n }\n createIndexes(\n _indexSpecs: IndexDescription[],\n _options?: CreateIndexesOptions | undefined,\n ): Promise<string[]> {\n throw new Error('Method not implemented.');\n }\n dropIndex(\n _indexName: string,\n _options?: CommandOperationOptions | undefined,\n ): Promise<Document> {\n throw new Error('Method not implemented.');\n }\n dropIndexes(\n _options?: CommandOperationOptions | undefined,\n ): Promise<boolean> {\n throw new Error('Method not implemented.');\n }\n listIndexes(_options?: AbstractCursorOptions | undefined): ListIndexesCursor {\n throw new Error('Method not implemented.');\n }\n indexExists(\n _indexes: string | string[],\n _options?: AbstractCursorOptions | undefined,\n ): Promise<boolean> {\n throw new Error('Method not implemented.');\n }\n indexInformation(\n options: IndexInformationOptions & { full: true },\n ): Promise<IndexDescriptionInfo[]>;\n indexInformation(\n options: IndexInformationOptions & { full?: false | undefined },\n ): Promise<IndexDescriptionCompact>;\n indexInformation(\n options: IndexInformationOptions,\n ): Promise<IndexDescriptionCompact | IndexDescriptionInfo[]>;\n indexInformation(): Promise<IndexDescriptionCompact>;\n indexInformation(\n _options?: unknown,\n ):\n | Promise<import('mongodb').IndexDescriptionInfo[]>\n | Promise<import('mongodb').IndexDescriptionCompact>\n | Promise<\n | import('mongodb').IndexDescriptionCompact\n | import('mongodb').IndexDescriptionInfo[]\n > {\n throw new Error('Method not implemented.');\n }\n estimatedDocumentCount(\n _options?: EstimatedDocumentCountOptions | undefined,\n ): Promise<number> {\n return this.collection.countDocuments();\n }\n countDocuments(\n filter?: Filter<T> | undefined,\n _options?: CountDocumentsOptions | undefined,\n ): Promise<number> {\n return this.collection.countDocuments(filter as PongoFilter<T>);\n }\n distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(\n key: Key,\n ): Promise<Flatten<WithId<T>[Key]>[]>;\n distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(\n key: Key,\n filter: Filter<T>,\n ): Promise<Flatten<WithId<T>[Key]>[]>;\n distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(\n key: Key,\n filter: Filter<T>,\n options: CommandOperationOptions,\n ): Promise<Flatten<WithId<T>[Key]>[]>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n distinct(key: string): Promise<any[]>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n distinct(key: string, filter: Filter<T>): Promise<any[]>;\n distinct(\n key: string,\n filter: Filter<T>,\n options: CommandOperationOptions, // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): Promise<any[]>;\n distinct(\n _key: unknown,\n _filter?: unknown,\n _options?: unknown,\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Promise<any[]>\n | Promise<import('mongodb').Flatten<import('mongodb').WithId<T>[Key]>[]> {\n throw new Error('Method not implemented.');\n }\n indexes(\n options: IndexInformationOptions & { full?: true | undefined },\n ): Promise<IndexDescriptionInfo[]>;\n indexes(\n options: IndexInformationOptions & { full: false },\n ): Promise<IndexDescriptionCompact>;\n indexes(\n options: IndexInformationOptions,\n ): Promise<IndexDescriptionCompact | IndexDescriptionInfo[]>;\n indexes(\n options?: AbstractCursorOptions | undefined,\n ): Promise<IndexDescriptionInfo[]>;\n indexes(\n _options?: unknown,\n ):\n | Promise<import('mongodb').IndexDescriptionInfo[]>\n | Promise<import('mongodb').IndexDescriptionCompact>\n | Promise<\n | import('mongodb').IndexDescriptionCompact\n | import('mongodb').IndexDescriptionInfo[]\n > {\n throw new Error('Method not implemented.');\n }\n findOneAndDelete(\n filter: Filter<T>,\n options: FindOneAndDeleteOptions & { includeResultMetadata: true },\n ): Promise<ModifyResult<T>>;\n findOneAndDelete(\n filter: Filter<T>,\n options: FindOneAndDeleteOptions & { includeResultMetadata: false },\n ): Promise<WithId<T> | null>;\n findOneAndDelete(\n filter: Filter<T>,\n options: FindOneAndDeleteOptions,\n ): Promise<WithId<T> | null>;\n findOneAndDelete(filter: Filter<T>): Promise<WithId<T> | null>;\n findOneAndDelete(\n filter: unknown,\n _options?: unknown,\n ): Promise<WithId<T> | null | ModifyResult<T>> {\n return this.collection.findOneAndDelete(\n filter as PongoFilter<T>,\n ) as Promise<WithId<T> | null>;\n }\n findOneAndReplace(\n filter: Filter<T>,\n replacement: WithoutId<T>,\n options: FindOneAndReplaceOptions & { includeResultMetadata: true },\n ): Promise<ModifyResult<T>>;\n findOneAndReplace(\n filter: Filter<T>,\n replacement: WithoutId<T>,\n options: FindOneAndReplaceOptions & { includeResultMetadata: false },\n ): Promise<WithId<T> | null>;\n findOneAndReplace(\n filter: Filter<T>,\n replacement: WithoutId<T>,\n options: FindOneAndReplaceOptions,\n ): Promise<WithId<T> | null>;\n findOneAndReplace(\n filter: Filter<T>,\n replacement: WithoutId<T>,\n ): Promise<WithId<T> | null>;\n findOneAndReplace(\n filter: unknown,\n replacement: unknown,\n _options?: unknown,\n ): Promise<WithId<T> | null | ModifyResult<T>> {\n return this.collection.findOneAndReplace(\n filter as PongoFilter<T>,\n replacement as WithoutId<T>,\n ) as Promise<WithId<T> | null>;\n }\n findOneAndUpdate(\n filter: Filter<T>,\n update: UpdateFilter<T>,\n options: FindOneAndUpdateOptions & { includeResultMetadata: true },\n ): Promise<ModifyResult<T>>;\n findOneAndUpdate(\n filter: Filter<T>,\n update: UpdateFilter<T>,\n options: FindOneAndUpdateOptions & { includeResultMetadata: false },\n ): Promise<WithId<T> | null>;\n findOneAndUpdate(\n filter: Filter<T>,\n update: UpdateFilter<T>,\n options: FindOneAndUpdateOptions,\n ): Promise<WithId<T> | null>;\n findOneAndUpdate(\n filter: Filter<T>,\n update: UpdateFilter<T>,\n ): Promise<WithId<T> | null>;\n findOneAndUpdate(\n filter: unknown,\n update: unknown,\n _options?: unknown,\n ): Promise<WithId<T> | null | ModifyResult<T>> {\n return this.collection.findOneAndUpdate(\n filter as PongoFilter<T>,\n update as PongoUpdate<T>,\n ) as Promise<WithId<T> | null>;\n }\n aggregate<T extends Document = Document>(\n _pipeline?: Document[] | undefined,\n _options?: AggregateOptions | undefined,\n ): AggregationCursor<T> {\n throw new Error('Method not implemented.');\n }\n watch<\n TLocal extends Document = T,\n TChange extends Document = ChangeStreamDocument<TLocal>,\n >(\n _pipeline?: Document[] | undefined,\n _options?: ChangeStreamOptions | undefined,\n ): ChangeStream<TLocal, TChange> {\n throw new Error('Method not implemented.');\n }\n initializeUnorderedBulkOp(\n _options?: BulkWriteOptions | undefined,\n ): UnorderedBulkOperation {\n throw new Error('Method not implemented.');\n }\n initializeOrderedBulkOp(\n _options?: BulkWriteOptions | undefined,\n ): OrderedBulkOperation {\n throw new Error('Method not implemented.');\n }\n count(\n filter?: Filter<T> | undefined,\n _options?: CountOptions | undefined,\n ): Promise<number> {\n return this.collection.countDocuments((filter as PongoFilter<T>) ?? {});\n }\n listSearchIndexes(\n options?: ListSearchIndexesOptions | undefined,\n ): ListSearchIndexesCursor;\n listSearchIndexes(\n name: string,\n options?: ListSearchIndexesOptions | undefined,\n ): ListSearchIndexesCursor;\n listSearchIndexes(\n _name?: unknown,\n _options?: unknown,\n ): import('mongodb').ListSearchIndexesCursor {\n throw new Error('Method not implemented.');\n }\n createSearchIndex(_description: SearchIndexDescription): Promise<string> {\n throw new Error('Method not implemented.');\n }\n createSearchIndexes(\n _descriptions: SearchIndexDescription[],\n ): Promise<string[]> {\n throw new Error('Method not implemented.');\n }\n dropSearchIndex(_name: string): Promise<void> {\n throw new Error('Method not implemented.');\n }\n updateSearchIndex(_name: string, _definition: Document): Promise<void> {\n throw new Error('Method not implemented.');\n }\n\n async createCollection(): Promise<void> {\n await this.collection.createCollection();\n }\n async handle(id: ObjectId, handle: DocumentHandler<T>): Promise<T | null> {\n return this.collection.handle(id.toString(), handle);\n }\n}\n","// src/MongoClientShim.ts\nimport { pongoClient, type PongoClient } from '../main';\nimport { Db } from './mongoDb';\n\nexport class MongoClient {\n private pongoClient: PongoClient;\n\n constructor(connectionString: string) {\n this.pongoClient = pongoClient(connectionString);\n }\n\n async connect() {\n await this.pongoClient.connect();\n return this;\n }\n\n async close() {\n await this.pongoClient.close();\n }\n\n db(dbName?: string): Db {\n return new Db(this.pongoClient.db(dbName));\n }\n}\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,58 @@
|
|
|
1
|
-
import { Document, Collection as Collection$1, ReadConcern, ReadPreference, BSONSerializeOptions, WriteConcern, Hint, OptionalUnlessRequiredId, InsertOneOptions, InsertOneResult, BulkWriteOptions, InsertManyResult, AnyBulkWriteOperation, BulkWriteResult, Filter, UpdateFilter, UpdateOptions, UpdateResult, WithoutId, ReplaceOptions, DeleteOptions, DeleteResult, RenameOptions, DropCollectionOptions, WithId as WithId$1, FindOptions, FindCursor as FindCursor$1, OperationOptions, IndexSpecification, CreateIndexesOptions, IndexDescription, CommandOperationOptions, AbstractCursorOptions, ListIndexesCursor, IndexInformationOptions, IndexDescriptionInfo, IndexDescriptionCompact, EstimatedDocumentCountOptions, CountDocumentsOptions, EnhancedOmit, Flatten, FindOneAndDeleteOptions, ModifyResult, FindOneAndReplaceOptions, FindOneAndUpdateOptions, AggregateOptions, AggregationCursor, ChangeStreamDocument, ChangeStreamOptions, ChangeStream, UnorderedBulkOperation, OrderedBulkOperation, CountOptions, ListSearchIndexesOptions, ListSearchIndexesCursor, SearchIndexDescription } from 'mongodb';
|
|
2
|
-
import { SQL } from '@event-driven-io/dumbo';
|
|
3
1
|
import pg from 'pg';
|
|
2
|
+
import { Document, Collection as Collection$1, ObjectId as ObjectId$1, ReadConcern, ReadPreference, BSONSerializeOptions, WriteConcern, Hint, OptionalUnlessRequiredId, InsertOneOptions, InsertOneResult, BulkWriteOptions, InsertManyResult, AnyBulkWriteOperation, BulkWriteResult, Filter, UpdateFilter, UpdateOptions, UpdateResult, WithoutId as WithoutId$1, ReplaceOptions, DeleteOptions, DeleteResult, RenameOptions, DropCollectionOptions, WithId as WithId$1, FindOptions, FindCursor as FindCursor$1, OperationOptions, IndexSpecification, CreateIndexesOptions, IndexDescription, CommandOperationOptions, AbstractCursorOptions, ListIndexesCursor, IndexInformationOptions, IndexDescriptionInfo, IndexDescriptionCompact, EstimatedDocumentCountOptions, CountDocumentsOptions, EnhancedOmit, Flatten, FindOneAndDeleteOptions, ModifyResult, FindOneAndReplaceOptions, FindOneAndUpdateOptions, AggregateOptions, AggregationCursor, ChangeStreamDocument, ChangeStreamOptions, ChangeStream, UnorderedBulkOperation, OrderedBulkOperation, CountOptions, ListSearchIndexesOptions, ListSearchIndexesCursor, SearchIndexDescription } from 'mongodb';
|
|
3
|
+
import { SQL } from '@event-driven-io/dumbo';
|
|
4
|
+
|
|
5
|
+
type PongoClientOptions = {
|
|
6
|
+
connectionString: string;
|
|
7
|
+
dbName?: string | undefined;
|
|
8
|
+
client?: pg.PoolClient;
|
|
9
|
+
};
|
|
10
|
+
declare const postgresClient: (options: PongoClientOptions) => DbClient;
|
|
11
|
+
|
|
12
|
+
declare const Operators: {
|
|
13
|
+
$eq: string;
|
|
14
|
+
$gt: string;
|
|
15
|
+
$gte: string;
|
|
16
|
+
$lt: string;
|
|
17
|
+
$lte: string;
|
|
18
|
+
$ne: string;
|
|
19
|
+
$in: string;
|
|
20
|
+
$nin: string;
|
|
21
|
+
$elemMatch: string;
|
|
22
|
+
$all: string;
|
|
23
|
+
$size: string;
|
|
24
|
+
};
|
|
25
|
+
declare const isOperator: (key: string) => boolean;
|
|
26
|
+
declare const hasOperators: (value: Record<string, unknown>) => boolean;
|
|
27
|
+
declare const handleOperator: (path: string, operator: string, value: unknown) => string;
|
|
28
|
+
|
|
29
|
+
declare const constructFilterQuery: <T>(filter: PongoFilter<T>) => string;
|
|
30
|
+
|
|
31
|
+
declare const postgresCollection: <T extends PongoDocument>(collectionName: string, { dbName, poolOrClient: clientOrPool, }: {
|
|
32
|
+
dbName: string;
|
|
33
|
+
poolOrClient: pg.Pool | pg.PoolClient;
|
|
34
|
+
}) => PongoCollection<T>;
|
|
35
|
+
declare const collectionSQLBuilder: (collectionName: string) => {
|
|
36
|
+
createCollection: () => SQL;
|
|
37
|
+
insertOne: <T>(document: WithId<T>) => SQL;
|
|
38
|
+
insertMany: <T_1>(documents: WithId<T_1>[]) => SQL;
|
|
39
|
+
updateOne: <T_2>(filter: PongoFilter<T_2>, update: PongoUpdate<T_2>) => SQL;
|
|
40
|
+
replaceOne: <T_3>(filter: PongoFilter<T_3>, document: WithoutId<T_3>) => SQL;
|
|
41
|
+
updateMany: <T_4>(filter: PongoFilter<T_4>, update: PongoUpdate<T_4>) => SQL;
|
|
42
|
+
deleteOne: <T_5>(filter: PongoFilter<T_5>) => SQL;
|
|
43
|
+
deleteMany: <T_6>(filter: PongoFilter<T_6>) => SQL;
|
|
44
|
+
findOne: <T_7>(filter: PongoFilter<T_7>) => SQL;
|
|
45
|
+
find: <T_8>(filter: PongoFilter<T_8>) => SQL;
|
|
46
|
+
countDocuments: <T_9>(filter: PongoFilter<T_9>) => SQL;
|
|
47
|
+
rename: (newName: string) => SQL;
|
|
48
|
+
drop: (targetName?: string) => SQL;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
declare const buildUpdateQuery: <T>(update: PongoUpdate<T>) => SQL;
|
|
52
|
+
declare const buildSetQuery: <T>(set: $set<T>, currentUpdateQuery: SQL) => SQL;
|
|
53
|
+
declare const buildUnsetQuery: <T>(unset: $unset<T>, currentUpdateQuery: SQL) => SQL;
|
|
54
|
+
declare const buildIncQuery: <T>(inc: $inc<T>, currentUpdateQuery: SQL) => SQL;
|
|
55
|
+
declare const buildPushQuery: <T>(push: $push<T>, currentUpdateQuery: SQL) => SQL;
|
|
4
56
|
|
|
5
57
|
interface PongoClient {
|
|
6
58
|
connect(): Promise<this>;
|
|
@@ -8,23 +60,34 @@ interface PongoClient {
|
|
|
8
60
|
db(dbName?: string): PongoDb;
|
|
9
61
|
}
|
|
10
62
|
interface PongoDb {
|
|
11
|
-
collection<T>(name: string): PongoCollection<T>;
|
|
63
|
+
collection<T extends PongoDocument>(name: string): PongoCollection<T>;
|
|
12
64
|
}
|
|
13
|
-
interface PongoCollection<T> {
|
|
65
|
+
interface PongoCollection<T extends PongoDocument> {
|
|
66
|
+
readonly dbName: string;
|
|
67
|
+
readonly collectionName: string;
|
|
14
68
|
createCollection(): Promise<void>;
|
|
15
69
|
insertOne(document: T): Promise<PongoInsertOneResult>;
|
|
16
70
|
insertMany(documents: T[]): Promise<PongoInsertManyResult>;
|
|
17
71
|
updateOne(filter: PongoFilter<T>, update: PongoUpdate<T>): Promise<PongoUpdateResult>;
|
|
72
|
+
replaceOne(filter: PongoFilter<T>, document: WithoutId<T>): Promise<PongoUpdateResult>;
|
|
18
73
|
updateMany(filter: PongoFilter<T>, update: PongoUpdate<T>): Promise<PongoUpdateResult>;
|
|
19
|
-
deleteOne(filter
|
|
20
|
-
deleteMany(filter
|
|
21
|
-
findOne(filter
|
|
22
|
-
find(filter
|
|
74
|
+
deleteOne(filter?: PongoFilter<T>): Promise<PongoDeleteResult>;
|
|
75
|
+
deleteMany(filter?: PongoFilter<T>): Promise<PongoDeleteResult>;
|
|
76
|
+
findOne(filter?: PongoFilter<T>): Promise<T | null>;
|
|
77
|
+
find(filter?: PongoFilter<T>): Promise<T[]>;
|
|
78
|
+
findOneAndDelete(filter: PongoFilter<T>): Promise<T | null>;
|
|
79
|
+
findOneAndReplace(filter: PongoFilter<T>, replacement: WithoutId<T>): Promise<T | null>;
|
|
80
|
+
findOneAndUpdate(filter: PongoFilter<T>, update: PongoUpdate<T>): Promise<T | null>;
|
|
81
|
+
countDocuments(filter?: PongoFilter<T>): Promise<number>;
|
|
82
|
+
drop(): Promise<boolean>;
|
|
83
|
+
rename(newName: string): Promise<PongoCollection<T>>;
|
|
84
|
+
handle(id: string, handle: DocumentHandler<T>): Promise<T | null>;
|
|
23
85
|
}
|
|
24
86
|
type HasId = {
|
|
25
87
|
_id: string;
|
|
26
88
|
};
|
|
27
89
|
type WithId<T> = T & HasId;
|
|
90
|
+
type WithoutId<T> = Omit<T, '_id'>;
|
|
28
91
|
type PongoFilter<T> = {
|
|
29
92
|
[P in keyof T]?: T[P] | PongoFilterOperator<T[P]>;
|
|
30
93
|
} | HasId;
|
|
@@ -79,15 +142,17 @@ interface PongoDeleteManyResult {
|
|
|
79
142
|
acknowledged: boolean;
|
|
80
143
|
deletedCount: number;
|
|
81
144
|
}
|
|
82
|
-
|
|
83
|
-
|
|
145
|
+
type PongoDocument = Record<string, unknown>;
|
|
146
|
+
type DocumentHandler<T extends PongoDocument> = ((document: T | null) => T | null) | ((document: T | null) => Promise<T | null>);
|
|
84
147
|
|
|
85
148
|
interface DbClient {
|
|
86
149
|
connect(): Promise<void>;
|
|
87
150
|
close(): Promise<void>;
|
|
88
|
-
collection: <T>(name: string) => PongoCollection<T>;
|
|
151
|
+
collection: <T extends PongoDocument>(name: string) => PongoCollection<T>;
|
|
89
152
|
}
|
|
90
|
-
declare const getDbClient: (
|
|
153
|
+
declare const getDbClient: (options: PongoClientOptions) => DbClient;
|
|
154
|
+
|
|
155
|
+
declare const pongoClient: (connectionString: string) => PongoClient;
|
|
91
156
|
|
|
92
157
|
type Entry<T> = {
|
|
93
158
|
[K in keyof Required<T>]: [K, Required<T>[K]];
|
|
@@ -115,7 +180,9 @@ declare class FindCursor<T> {
|
|
|
115
180
|
declare class Db {
|
|
116
181
|
private pongoDb;
|
|
117
182
|
constructor(pongoDb: PongoDb);
|
|
118
|
-
collection<T extends Document>(collectionName: string): Collection$1<T
|
|
183
|
+
collection<T extends Document>(collectionName: string): Collection$1<T> & {
|
|
184
|
+
handle(id: ObjectId$1, handle: DocumentHandler<T>): Promise<T | null>;
|
|
185
|
+
};
|
|
119
186
|
}
|
|
120
187
|
|
|
121
188
|
declare class MongoClient {
|
|
@@ -142,11 +209,11 @@ declare class Collection<T extends Document> implements Collection$1<T> {
|
|
|
142
209
|
insertMany(docs: OptionalUnlessRequiredId<T>[], _options?: BulkWriteOptions | undefined): Promise<InsertManyResult<T>>;
|
|
143
210
|
bulkWrite(_operations: AnyBulkWriteOperation<T>[], _options?: BulkWriteOptions | undefined): Promise<BulkWriteResult>;
|
|
144
211
|
updateOne(filter: Filter<T>, update: Document[] | UpdateFilter<T>, _options?: UpdateOptions | undefined): Promise<UpdateResult<T>>;
|
|
145
|
-
replaceOne(
|
|
212
|
+
replaceOne(filter: Filter<T>, document: WithoutId$1<T>, _options?: ReplaceOptions | undefined): Promise<Document | UpdateResult<T>>;
|
|
146
213
|
updateMany(filter: Filter<T>, update: Document[] | UpdateFilter<T>, _options?: UpdateOptions | undefined): Promise<UpdateResult<T>>;
|
|
147
214
|
deleteOne(filter?: Filter<T> | undefined, _options?: DeleteOptions | undefined): Promise<DeleteResult>;
|
|
148
215
|
deleteMany(filter?: Filter<T> | undefined, _options?: DeleteOptions | undefined): Promise<DeleteResult>;
|
|
149
|
-
rename(
|
|
216
|
+
rename(newName: string, _options?: RenameOptions | undefined): Promise<Collection<Document>>;
|
|
150
217
|
drop(_options?: DropCollectionOptions | undefined): Promise<boolean>;
|
|
151
218
|
findOne(): Promise<WithId$1<T> | null>;
|
|
152
219
|
findOne(filter: Filter<T>): Promise<WithId$1<T> | null>;
|
|
@@ -174,7 +241,7 @@ declare class Collection<T extends Document> implements Collection$1<T> {
|
|
|
174
241
|
indexInformation(options: IndexInformationOptions): Promise<IndexDescriptionCompact | IndexDescriptionInfo[]>;
|
|
175
242
|
indexInformation(): Promise<IndexDescriptionCompact>;
|
|
176
243
|
estimatedDocumentCount(_options?: EstimatedDocumentCountOptions | undefined): Promise<number>;
|
|
177
|
-
countDocuments(
|
|
244
|
+
countDocuments(filter?: Filter<T> | undefined, _options?: CountDocumentsOptions | undefined): Promise<number>;
|
|
178
245
|
distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(key: Key): Promise<Flatten<WithId$1<T>[Key]>[]>;
|
|
179
246
|
distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(key: Key, filter: Filter<T>): Promise<Flatten<WithId$1<T>[Key]>[]>;
|
|
180
247
|
distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(key: Key, filter: Filter<T>, options: CommandOperationOptions): Promise<Flatten<WithId$1<T>[Key]>[]>;
|
|
@@ -197,14 +264,14 @@ declare class Collection<T extends Document> implements Collection$1<T> {
|
|
|
197
264
|
}): Promise<WithId$1<T> | null>;
|
|
198
265
|
findOneAndDelete(filter: Filter<T>, options: FindOneAndDeleteOptions): Promise<WithId$1<T> | null>;
|
|
199
266
|
findOneAndDelete(filter: Filter<T>): Promise<WithId$1<T> | null>;
|
|
200
|
-
findOneAndReplace(filter: Filter<T>, replacement: WithoutId<T>, options: FindOneAndReplaceOptions & {
|
|
267
|
+
findOneAndReplace(filter: Filter<T>, replacement: WithoutId$1<T>, options: FindOneAndReplaceOptions & {
|
|
201
268
|
includeResultMetadata: true;
|
|
202
269
|
}): Promise<ModifyResult<T>>;
|
|
203
|
-
findOneAndReplace(filter: Filter<T>, replacement: WithoutId<T>, options: FindOneAndReplaceOptions & {
|
|
270
|
+
findOneAndReplace(filter: Filter<T>, replacement: WithoutId$1<T>, options: FindOneAndReplaceOptions & {
|
|
204
271
|
includeResultMetadata: false;
|
|
205
272
|
}): Promise<WithId$1<T> | null>;
|
|
206
|
-
findOneAndReplace(filter: Filter<T>, replacement: WithoutId<T>, options: FindOneAndReplaceOptions): Promise<WithId$1<T> | null>;
|
|
207
|
-
findOneAndReplace(filter: Filter<T>, replacement: WithoutId<T>): Promise<WithId$1<T> | null>;
|
|
273
|
+
findOneAndReplace(filter: Filter<T>, replacement: WithoutId$1<T>, options: FindOneAndReplaceOptions): Promise<WithId$1<T> | null>;
|
|
274
|
+
findOneAndReplace(filter: Filter<T>, replacement: WithoutId$1<T>): Promise<WithId$1<T> | null>;
|
|
208
275
|
findOneAndUpdate(filter: Filter<T>, update: UpdateFilter<T>, options: FindOneAndUpdateOptions & {
|
|
209
276
|
includeResultMetadata: true;
|
|
210
277
|
}): Promise<ModifyResult<T>>;
|
|
@@ -217,7 +284,7 @@ declare class Collection<T extends Document> implements Collection$1<T> {
|
|
|
217
284
|
watch<TLocal extends Document = T, TChange extends Document = ChangeStreamDocument<TLocal>>(_pipeline?: Document[] | undefined, _options?: ChangeStreamOptions | undefined): ChangeStream<TLocal, TChange>;
|
|
218
285
|
initializeUnorderedBulkOp(_options?: BulkWriteOptions | undefined): UnorderedBulkOperation;
|
|
219
286
|
initializeOrderedBulkOp(_options?: BulkWriteOptions | undefined): OrderedBulkOperation;
|
|
220
|
-
count(
|
|
287
|
+
count(filter?: Filter<T> | undefined, _options?: CountOptions | undefined): Promise<number>;
|
|
221
288
|
listSearchIndexes(options?: ListSearchIndexesOptions | undefined): ListSearchIndexesCursor;
|
|
222
289
|
listSearchIndexes(name: string, options?: ListSearchIndexesOptions | undefined): ListSearchIndexesCursor;
|
|
223
290
|
createSearchIndex(_description: SearchIndexDescription): Promise<string>;
|
|
@@ -225,50 +292,11 @@ declare class Collection<T extends Document> implements Collection$1<T> {
|
|
|
225
292
|
dropSearchIndex(_name: string): Promise<void>;
|
|
226
293
|
updateSearchIndex(_name: string, _definition: Document): Promise<void>;
|
|
227
294
|
createCollection(): Promise<void>;
|
|
295
|
+
handle(id: ObjectId$1, handle: DocumentHandler<T>): Promise<T | null>;
|
|
228
296
|
}
|
|
229
297
|
|
|
230
298
|
type ObjectId = string & {
|
|
231
299
|
__brandId: 'ObjectId';
|
|
232
300
|
};
|
|
233
301
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
declare const Operators: {
|
|
237
|
-
$eq: string;
|
|
238
|
-
$gt: string;
|
|
239
|
-
$gte: string;
|
|
240
|
-
$lt: string;
|
|
241
|
-
$lte: string;
|
|
242
|
-
$ne: string;
|
|
243
|
-
$in: string;
|
|
244
|
-
$nin: string;
|
|
245
|
-
$elemMatch: string;
|
|
246
|
-
$all: string;
|
|
247
|
-
$size: string;
|
|
248
|
-
};
|
|
249
|
-
declare const isOperator: (key: string) => boolean;
|
|
250
|
-
declare const hasOperators: (value: Record<string, unknown>) => boolean;
|
|
251
|
-
declare const handleOperator: (path: string, operator: string, value: unknown) => string;
|
|
252
|
-
|
|
253
|
-
declare const constructFilterQuery: <T>(filter: PongoFilter<T>) => string;
|
|
254
|
-
|
|
255
|
-
declare const postgresCollection: <T>(collectionName: string, pool: pg.Pool) => PongoCollection<T>;
|
|
256
|
-
declare const collectionSQLBuilder: (collectionName: string) => {
|
|
257
|
-
createCollection: () => SQL;
|
|
258
|
-
insertOne: <T>(document: WithId<T>) => SQL;
|
|
259
|
-
insertMany: <T_1>(documents: WithId<T_1>[]) => SQL;
|
|
260
|
-
updateOne: <T_2>(filter: PongoFilter<T_2>, update: PongoUpdate<T_2>) => SQL;
|
|
261
|
-
updateMany: <T_3>(filter: PongoFilter<T_3>, update: PongoUpdate<T_3>) => SQL;
|
|
262
|
-
deleteOne: <T_4>(filter: PongoFilter<T_4>) => SQL;
|
|
263
|
-
deleteMany: <T_5>(filter: PongoFilter<T_5>) => SQL;
|
|
264
|
-
findOne: <T_6>(filter: PongoFilter<T_6>) => SQL;
|
|
265
|
-
find: <T_7>(filter: PongoFilter<T_7>) => SQL;
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
declare const buildUpdateQuery: <T>(update: PongoUpdate<T>) => SQL;
|
|
269
|
-
declare const buildSetQuery: <T>(set: $set<T>, currentUpdateQuery: SQL) => SQL;
|
|
270
|
-
declare const buildUnsetQuery: <T>(unset: $unset<T>, currentUpdateQuery: SQL) => SQL;
|
|
271
|
-
declare const buildIncQuery: <T>(inc: $inc<T>, currentUpdateQuery: SQL) => SQL;
|
|
272
|
-
declare const buildPushQuery: <T>(push: $push<T>, currentUpdateQuery: SQL) => SQL;
|
|
273
|
-
|
|
274
|
-
export { type $inc, type $push, type $set, type $unset, Collection, Db, type DbClient, FindCursor, type HasId, MongoClient, type NonPartial, type ObjectId, Operators, type PongoClient, type PongoCollection, type PongoDb, type PongoDeleteManyResult, type PongoDeleteResult, type PongoFilter, type PongoFilterOperator, type PongoInsertManyResult, type PongoInsertOneResult, type PongoUpdate, type PongoUpdateManyResult, type PongoUpdateResult, type WithId, buildIncQuery, buildPushQuery, buildSetQuery, buildUnsetQuery, buildUpdateQuery, collectionSQLBuilder, constructFilterQuery, entries, getDbClient, handleOperator, hasOperators, isOperator, pongoClient, postgresClient, postgresCollection };
|
|
302
|
+
export { type $inc, type $push, type $set, type $unset, Collection, Db, type DbClient, type DocumentHandler, FindCursor, type HasId, MongoClient, type NonPartial, type ObjectId, Operators, type PongoClient, type PongoClientOptions, type PongoCollection, type PongoDb, type PongoDeleteManyResult, type PongoDeleteResult, type PongoDocument, type PongoFilter, type PongoFilterOperator, type PongoInsertManyResult, type PongoInsertOneResult, type PongoUpdate, type PongoUpdateManyResult, type PongoUpdateResult, type WithId, type WithoutId, buildIncQuery, buildPushQuery, buildSetQuery, buildUnsetQuery, buildUpdateQuery, collectionSQLBuilder, constructFilterQuery, entries, getDbClient, handleOperator, hasOperators, isOperator, pongoClient, postgresClient, postgresCollection };
|