effect-mongodb 0.1.3 → 0.2.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.
Files changed (73) hide show
  1. package/README.md +25 -19
  2. package/dist/cjs/AggregationCursor.js +10 -4
  3. package/dist/cjs/AggregationCursor.js.map +1 -1
  4. package/dist/cjs/Collection.js +19 -14
  5. package/dist/cjs/Collection.js.map +1 -1
  6. package/dist/cjs/Db.js +11 -9
  7. package/dist/cjs/Db.js.map +1 -1
  8. package/dist/cjs/DocumentAggregationCursor.js +10 -4
  9. package/dist/cjs/DocumentAggregationCursor.js.map +1 -1
  10. package/dist/cjs/DocumentCollection.js +15 -9
  11. package/dist/cjs/DocumentCollection.js.map +1 -1
  12. package/dist/cjs/DocumentFindCursor.js +16 -10
  13. package/dist/cjs/DocumentFindCursor.js.map +1 -1
  14. package/dist/cjs/FindCursor.js +15 -9
  15. package/dist/cjs/FindCursor.js.map +1 -1
  16. package/dist/cjs/ListCollectionsCursor.js +10 -4
  17. package/dist/cjs/ListCollectionsCursor.js.map +1 -1
  18. package/dist/cjs/MongoClient.js +17 -5
  19. package/dist/cjs/MongoClient.js.map +1 -1
  20. package/dist/cjs/internal/schema.js +2 -2
  21. package/dist/cjs/internal/schema.js.map +1 -1
  22. package/dist/cjs/internal/version.js +1 -1
  23. package/dist/dts/AggregationCursor.d.ts +5 -5
  24. package/dist/dts/AggregationCursor.d.ts.map +1 -1
  25. package/dist/dts/Collection.d.ts +5 -6
  26. package/dist/dts/Collection.d.ts.map +1 -1
  27. package/dist/dts/Db.d.ts +9 -5
  28. package/dist/dts/Db.d.ts.map +1 -1
  29. package/dist/dts/DocumentAggregationCursor.d.ts +5 -5
  30. package/dist/dts/DocumentAggregationCursor.d.ts.map +1 -1
  31. package/dist/dts/DocumentCollection.d.ts +5 -5
  32. package/dist/dts/DocumentCollection.d.ts.map +1 -1
  33. package/dist/dts/DocumentFindCursor.d.ts +5 -5
  34. package/dist/dts/DocumentFindCursor.d.ts.map +1 -1
  35. package/dist/dts/FindCursor.d.ts +5 -5
  36. package/dist/dts/FindCursor.d.ts.map +1 -1
  37. package/dist/dts/ListCollectionsCursor.d.ts +5 -5
  38. package/dist/dts/ListCollectionsCursor.d.ts.map +1 -1
  39. package/dist/dts/MongoClient.d.ts +15 -9
  40. package/dist/dts/MongoClient.d.ts.map +1 -1
  41. package/dist/esm/AggregationCursor.js +8 -2
  42. package/dist/esm/AggregationCursor.js.map +1 -1
  43. package/dist/esm/Collection.js +17 -12
  44. package/dist/esm/Collection.js.map +1 -1
  45. package/dist/esm/Db.js +8 -7
  46. package/dist/esm/Db.js.map +1 -1
  47. package/dist/esm/DocumentAggregationCursor.js +8 -2
  48. package/dist/esm/DocumentAggregationCursor.js.map +1 -1
  49. package/dist/esm/DocumentCollection.js +13 -7
  50. package/dist/esm/DocumentCollection.js.map +1 -1
  51. package/dist/esm/DocumentFindCursor.js +14 -8
  52. package/dist/esm/DocumentFindCursor.js.map +1 -1
  53. package/dist/esm/FindCursor.js +13 -7
  54. package/dist/esm/FindCursor.js.map +1 -1
  55. package/dist/esm/ListCollectionsCursor.js +8 -2
  56. package/dist/esm/ListCollectionsCursor.js.map +1 -1
  57. package/dist/esm/MongoClient.js +15 -4
  58. package/dist/esm/MongoClient.js.map +1 -1
  59. package/dist/esm/internal/schema.js +2 -2
  60. package/dist/esm/internal/schema.js.map +1 -1
  61. package/dist/esm/internal/version.js +1 -1
  62. package/package.json +1 -1
  63. package/src/AggregationCursor.ts +20 -4
  64. package/src/Collection.ts +34 -13
  65. package/src/Db.ts +9 -7
  66. package/src/DocumentAggregationCursor.ts +16 -3
  67. package/src/DocumentCollection.ts +23 -8
  68. package/src/DocumentFindCursor.ts +23 -9
  69. package/src/FindCursor.ts +22 -8
  70. package/src/ListCollectionsCursor.ts +20 -5
  71. package/src/MongoClient.ts +14 -8
  72. package/src/internal/schema.ts +2 -2
  73. package/src/internal/version.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"DocumentFindCursor.js","names":["Data","Effect","F","Stream","FindCursor","mongoErrorOrDie","MongoError","DocumentFindCursor","TaggedClass","filter","dual","args","isDocumentFindCursor","cursor","project","value","sort","direction","limit","toArray","pipe","promise","catchAllDefect","errorSource","toStream","fromAsyncIterable","identity","catchAll","typed","schema","x","functionName","CollectionErrorSource","module","name","db","namespace","collection"],"sources":["../../src/DocumentFindCursor.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAGA,OAAO,KAAKA,IAAI,MAAM,aAAa;AACnC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,CAAC,MAAM,iBAAiB;AAEpC,OAAO,KAAKC,MAAM,MAAM,eAAe;AAEvC,OAAO,KAAKC,UAAU,MAAM,iBAAiB;AAC7C,SAASC,eAAe,QAAQ,2BAA2B;AAC3D,OAAO,KAAKC,UAAU,MAAM,iBAAiB;AAE7C,OAAM,MAAOC,kBAAmB,sBAAQP,IAAI,CAACQ,WAAW,CAAC,oBAAoB,CAE3E;AAGF,OAAO,MAAMC,MAAM,gBAGfP,CAAC,CAACQ,IAAI,CACPC,IAAI,IAAKC,oBAAoB,CAACD,IAAI,CAAC,CAAC,CAAC,CAAC,EACvC,CAACE,MAA0B,EAAEJ,MAAwB,KACnD,IAAIF,kBAAkB,CAAC;EAAEM,MAAM,EAAEA,MAAM,CAACA,MAAM,CAACJ,MAAM,CAACA,MAAM;AAAC,CAAE,CAAC,CACnE;AAED,OAAO,MAAMK,OAAO,gBAGhBZ,CAAC,CAACQ,IAAI,CACPC,IAAI,IAAKC,oBAAoB,CAACD,IAAI,CAAC,CAAC,CAAC,CAAC,EACvC,CAACE,MAA0B,EAAEE,KAAe,KAC1C,IAAIR,kBAAkB,CAAC;EAAEM,MAAM,EAAEA,MAAM,CAACA,MAAM,CAACC,OAAO,CAACC,KAAK;AAAC,CAAE,CAAC,CACnE;AAED,OAAO,MAAMC,IAAI,gBAGbd,CAAC,CAACQ,IAAI,CACPC,IAAI,I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EAAEgB;AAAM,CAAE,CAAC,CAAC;AAE3G,MAAMjB,oBAAoB,GAAIkB,CAAU,IAAKA,CAAC,YAAYvB,kBAAkB;AAE5E,MAAMgB,WAAW,GAAGA,CAACV,MAA0B,EAAEkB,YAAoB,KACnE,IAAIzB,UAAU,CAAC0B,qBAAqB,CAAC;EACnCC,MAAM,EAAE1B,kBAAkB,CAAC2B,IAAI;EAC/BH,YAAY;EACZI,EAAE,EAAEtB,MAAM,CAACA,MAAM,CAACuB,SAAS,CAACD,EAAE;EAC9BE,UAAU,EAAExB,MAAM,CAACA,MAAM,CAACuB,SAAS,CAACC,UAAU,IAAI;CACnD,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"DocumentFindCursor.js","names":["Data","Effect","F","pipeArguments","Stream","FindCursor","mongoErrorOrDie","MongoError","DocumentFindCursorImpl","TaggedClass","pipe","arguments","filter","dual","args","isDocumentFindCursor","cursor","project","value","sort","direction","limit","toArray","promise","catchAllDefect","errorSource","toStream","fromAsyncIterable","identity","catchAll","typed","schema","FindCursorImpl","x","functionName","CollectionErrorSource","module","name","db","namespace","collection"],"sources":["../../src/DocumentFindCursor.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAGA,OAAO,KAAKA,IAAI,MAAM,aAAa;AACnC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,CAAC,MAAM,iBAAiB;AAEpC,SAASC,aAAa,QAAQ,iBAAiB;AAE/C,OAAO,KAAKC,MAAM,MAAM,eAAe;AAEvC,OAAO,KAAKC,UAAU,MAAM,iBAAiB;AAC7C,SAASC,eAAe,QAAQ,2BAA2B;AAC3D,OAAO,KAAKC,UAAU,MAAM,iBAAiB;AAU7C;AACA,OAAM,MAAOC,sBAAuB,sBAAQR,IAAI,CAACS,WAAW,CAAC,oBAAoB,CAA2B;EAG1GC,IAAIA,CAAA;IACF,OAAOP,aAAa,CAAC,IAAI,EAAEQ,SAAS,CAAC;EACvC;;AAGF,OAAO,MAAMC,MAA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ACuB,cAAc,CAAClB,eAAe,CAACmB,WAAW,CAACT,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,CACvE;AAEH,OAAO,MAAMU,QAAQ,GACnBV,MAA0B,IAE1Bd,CAAC,CAACQ,IAAI,CACJN,MAAM,CAACuB,iBAAiB,CAACX,MAAM,CAACA,MAAM,EAAEd,CAAC,CAAC0B,QAAQ,CAAC,EACnDxB,MAAM,CAACyB,QAAQ,CAACvB,eAAe,CAACmB,WAAW,CAACT,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,CAClE;AAEH,OAAO,MAAMc,KAAK,gBAGd5B,CAAC,CAACW,IAAI,CAAEC,IAAI,IAAKC,oBAAoB,CAACD,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAClDE,MAA0B,EAC1Be,MAA8B,KACK,IAAI1B,UAAU,CAAC2B,cAAc,CAAU;EAAEhB,MAAM,EAAEA,MAAM,CAACA,MAAM;EAAEe;AAAM,CAAE,CAAC,CAAC;AAE/G,MAAMhB,oBAAoB,GAAIkB,CAAU,IAAKA,CAAC,YAAYzB,sBAAsB;AAEhF,MAAMiB,WAAW,GAAGA,CAACT,MAA0B,EAAEkB,YAAoB,KACnE,IAAI3B,UAAU,CAAC4B,qBAAqB,CAAC;EACnCC,MAAM,EAAE5B,sBAAsB,CAAC6B,IAAI;EACnCH,YAAY;EACZI,EAAE,EAAEtB,MAAM,CAACA,MAAM,CAACuB,SAAS,CAACD,EAAE;EAC9BE,UAAU,EAAExB,MAAM,CAACA,MAAM,CAACuB,SAAS,CAACC,UAAU,IAAI;CACnD,CAAC","ignoreList":[]}
@@ -4,25 +4,31 @@
4
4
  import * as Data from "effect/Data";
5
5
  import * as Effect from "effect/Effect";
6
6
  import * as F from "effect/Function";
7
+ import { pipeArguments } from "effect/Pipeable";
7
8
  import * as Schema from "effect/Schema";
8
9
  import * as Stream from "effect/Stream";
9
10
  import * as Tuple from "effect/Tuple";
10
11
  import { mongoErrorOrDie } from "./internal/mongo-error.js";
11
12
  import * as MongoError from "./MongoError.js";
12
- export class FindCursor extends /*#__PURE__*/Data.TaggedClass("FindCursor") {}
13
- export const filter = /*#__PURE__*/F.dual(args => isFindCursor(args[0]), (cursor, filter) => new FindCursor({
13
+ /** @internal */
14
+ export class FindCursorImpl extends /*#__PURE__*/Data.TaggedClass("FindCursor") {
15
+ pipe() {
16
+ return pipeArguments(this, arguments);
17
+ }
18
+ }
19
+ export const filter = /*#__PURE__*/F.dual(args => isFindCursor(args[0]), (cursor, filter) => new FindCursorImpl({
14
20
  cursor: cursor.cursor.filter(filter),
15
21
  schema: cursor.schema
16
22
  }));
17
- export const project = /*#__PURE__*/F.dual(args => isFindCursor(args[0]), (cursor, newSchema, value) => new FindCursor({
23
+ export const project = /*#__PURE__*/F.dual(args => isFindCursor(args[0]), (cursor, newSchema, value) => new FindCursorImpl({
18
24
  cursor: cursor.cursor.project(value),
19
25
  schema: newSchema
20
26
  }));
21
- export const sort = /*#__PURE__*/F.dual(args => isFindCursor(args[0]), (cursor, sort, direction) => new FindCursor({
27
+ export const sort = /*#__PURE__*/F.dual(args => isFindCursor(args[0]), (cursor, sort, direction) => new FindCursorImpl({
22
28
  cursor: cursor.cursor.sort(sort, direction),
23
29
  schema: cursor.schema
24
30
  }));
25
- export const limit = /*#__PURE__*/F.dual(args => isFindCursor(args[0]), (cursor, value) => new FindCursor({
31
+ export const limit = /*#__PURE__*/F.dual(args => isFindCursor(args[0]), (cursor, value) => new FindCursorImpl({
26
32
  cursor: cursor.cursor.limit(value),
27
33
  schema: cursor.schema
28
34
  }));
@@ -44,9 +50,9 @@ export const toStreamEither = cursor => {
44
50
  // keep new line
45
51
  decode(x), Effect.mapError(error => Tuple.make(x, error)), Effect.either)));
46
52
  };
47
- const isFindCursor = x => x instanceof FindCursor;
53
+ const isFindCursor = x => x instanceof FindCursorImpl;
48
54
  const errorSource = (cursor, functionName) => new MongoError.CollectionErrorSource({
49
- module: FindCursor.name,
55
+ module: FindCursorImpl.name,
50
56
  functionName,
51
57
  db: cursor.cursor.namespace.db,
52
58
  collection: cursor.cursor.namespace.collection ?? "NO_COLLECTION_NAME"
@@ -1 +1 @@
1
- {"version":3,"file":"FindCursor.js","names":["Data","Effect","F","Schema","Stream","Tuple","mongoErrorOrDie","MongoError","FindCursor","TaggedClass","filter","dual","args","isFindCursor","cursor","schema","project","newSchema","value","sort","direction","limit","toArray","decode","decodeUnknown","promise","pipe","catchAllDefect","errorSource","flatMap","forEach","x","toArrayEither","mapError","error","make","either","toStream","fromAsyncIterable","identity","catchAll","mapEffect","toStreamEither","functionName","CollectionErrorSource","module","name","db","namespace","collection"],"sources":["../../src/FindCursor.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAGA,OAAO,KAAKA,IAAI,MAAM,aAAa;AACnC,OAAO,KAAKC,MAAM,MAAM,eAAe;AAEvC,OAAO,KAAKC,CAAC,MAAM,iBAAiB;AAEpC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,KAAK,MAAM,cAAc;AAGrC,SAASC,eAAe,QAAQ,2BAA2B;AAC3D,OAAO,KAAKC,UAAU,MAAM,iBAAiB;AAE7C,OAAM,MAAOC,UAAgC,sBAAQR,IAAI,CAACS,WAAW,CAAC,YAAY,CAGhF;AAGF,OAAO,MAAMC,MAAM,gBAGfR,CAAC,CAACS,IAAI,CACPC,IAAI,IAAKC,YAAY,CAACD,IAAI,CAAC,CAAC,CAAC,CAAC,EAC/B,CACEE,MAA2B,EAC3BJ,MAAiB,KACO,IAAIF,UAAU,CAAC;EAAEM,MAAM,EAAEA,MAAM,CAACA,MAAM,CAACJ,MAAM,CAACA,MAAM,CAAC;EAAEK,MAAM,EAAED,MAAM,CAACC;AAAM,CAAE,CAAC,CAC1G;AAED,OAAO,MAAMC,OAAO,gBAUhBd,CAAC,CAACS,IAAI,CACPC,IAAI,IAAKC,YAAY,CAACD,IAAI,CAAC,CAAC,CAAC,CAAC,EAC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ACwB,IAAI,CACXtB,MAAM,CAACkC,iBAAiB,CAACxB,MAAM,CAACA,MAAM,EAAEZ,CAAC,CAACqC,QAAQ,CAAC,EACnDnC,MAAM,CAACoC,QAAQ,CAAClC,eAAe,CAACsB,WAAW,CAACd,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,EACvEV,MAAM,CAACqC,SAAS,CAAEV,CAAC,IACjB7B,CAAC,CAACwB,IAAI;EACJ;EACAH,MAAM,CAACQ,CAAC,CAAC,EACT9B,MAAM,CAACgC,QAAQ,CAAEC,KAAK,IAAK7B,KAAK,CAAC8B,IAAI,CAACJ,CAAC,EAAEG,KAAK,CAAC,CAAC,EAChDjC,MAAM,CAACmC,MAAM,CACd,CACF,CACF;AACH,CAAC;AAED,MAAMvB,YAAY,GAAIkB,CAAU,IAA+BA,CAAC,YAAYvB,UAAU;AAEtF,MAAMoB,WAAW,GAAGA,CAAUd,MAA2B,EAAE6B,YAAoB,KAC7E,IAAIpC,UAAU,CAACqC,qBAAqB,CAAC;EACnCC,MAAM,EAAErC,UAAU,CAACsC,IAAI;EACvBH,YAAY;EACZI,EAAE,EAAEjC,MAAM,CAACA,MAAM,CAACkC,SAAS,CAACD,EAAE;EAC9BE,UAAU,EAAEnC,MAAM,CAACA,MAAM,CAACkC,SAAS,CAACC,UAAU,IAAI;CACnD,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"FindCursor.js","names":["Data","Effect","F","pipeArguments","Schema","Stream","Tuple","mongoErrorOrDie","MongoError","FindCursorImpl","TaggedClass","pipe","arguments","filter","dual","args","isFindCursor","cursor","schema","project","newSchema","value","sort","direction","limit","toArray","decode","decodeUnknown","promise","catchAllDefect","errorSource","flatMap","forEach","x","toArrayEither","mapError","error","make","either","toStream","fromAsyncIterable","identity","catchAll","mapEffect","toStreamEither","functionName","CollectionErrorSource","module","name","db","namespace","collection"],"sources":["../../src/FindCursor.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAGA,OAAO,KAAKA,IAAI,MAA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K9B,KAAK,CAAC+B,IAAI,CAACJ,CAAC,EAAEG,KAAK,CAAC,CAAC,EAChDnC,MAAM,CAACqC,MAAM,CACd,CACF,CACF;AACH,CAAC;AAED,MAAMtB,YAAY,GAAIiB,CAAU,IAA+BA,CAAC,YAAYxB,cAAc;AAE1F,MAAMqB,WAAW,GAAGA,CAAUb,MAA2B,EAAE4B,YAAoB,KAC7E,IAAIrC,UAAU,CAACsC,qBAAqB,CAAC;EACnCC,MAAM,EAAEtC,cAAc,CAACuC,IAAI;EAC3BH,YAAY;EACZI,EAAE,EAAEhC,MAAM,CAACA,MAAM,CAACiC,SAAS,CAACD,EAAE;EAC9BE,UAAU,EAAElC,MAAM,CAACA,MAAM,CAACiC,SAAS,CAACC,UAAU,IAAI;CACnD,CAAC","ignoreList":[]}
@@ -4,14 +4,20 @@
4
4
  import * as Data from "effect/Data";
5
5
  import * as Effect from "effect/Effect";
6
6
  import * as F from "effect/Function";
7
+ import { pipeArguments } from "effect/Pipeable";
7
8
  import * as Stream from "effect/Stream";
8
9
  import { mongoErrorOrDie } from "./internal/mongo-error.js";
9
10
  import * as MongoError from "./MongoError.js";
10
- export class ListCollectionsCursor extends /*#__PURE__*/Data.TaggedClass("ListCollectionsCursor") {}
11
+ /** @internal */
12
+ export class ListCollectionsCursorImpl extends /*#__PURE__*/Data.TaggedClass("ListCollectionsCursor") {
13
+ pipe() {
14
+ return pipeArguments(this, arguments);
15
+ }
16
+ }
11
17
  export const toArray = cursor => F.pipe(Effect.promise(() => cursor.cursor.toArray()), Effect.catchAllDefect(mongoErrorOrDie(errorSource(cursor, "toArray"))));
12
18
  export const toStream = cursor => F.pipe(Stream.fromAsyncIterable(cursor.cursor, F.identity), Stream.catchAll(mongoErrorOrDie(errorSource(cursor, "toStream"))));
13
19
  const errorSource = (cursor, functionName) => new MongoError.CollectionErrorSource({
14
- module: ListCollectionsCursor.name,
20
+ module: ListCollectionsCursorImpl.name,
15
21
  functionName,
16
22
  db: cursor.cursor.namespace.db,
17
23
  collection: cursor.cursor.namespace.collection ?? "NO_COLLECTION_NAME"
@@ -1 +1 @@
1
- {"version":3,"file":"ListCollectionsCursor.js","names":["Data","Effect","F","Stream","mongoErrorOrDie","MongoError","ListCollectionsCursor","TaggedClass","toArray","cursor","pipe","promise","catchAllDefect","errorSource","toStream","fromAsyncIterable","identity","catchAll","functionName","CollectionErrorSource","module","name","db","namespace","collection"],"sources":["../../src/ListCollectionsCursor.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAGA,OAAO,KAAKA,IAAI,MAAM,aAAa;AACnC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,CAAC,MAAM,iBAAiB;AACpC,OAAO,KAAKC,MAAM,MAAM,eAAe;AAKvC,SAASC,eAAe,QAAQ,2BAA2B;AAC3D,OAAO,KAAKC,UAAU,MAAM,iBAAiB;AAO7C,OAAM,MAAOC,qBAEX,sBAAQN,IAAI,CAACO,WAAW,CAAC,uBAAuB,CAEhD;AAQF,OAAO,MAAMC,OAAO,GAClBC,MAAgC,IAEhCP,CAAC,CAACQ,IAAI,CACJT,MAAM,CAACU,OAAO,CAAC,MAAMF,MAAM,CAACA,MAAM,CAACD,OAAO,EAAE,CAAC,EAC7CP,MAAM,CAACW,cAAc,CAACR,eAAe,CAACS,WAAW,CAACJ,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,CACvE;AAEH,OAAO,MAAMK,QAAQ,GACnBL,MAAgC,IAEhCP,CAAC,CAACQ,IAAI,CACJP,MAAM,CAACY,iBAAiB,CAACN,MAAM,CAACA,MAAM,EAAEP,CAAC,CAACc,QAAQ,CAAC,EACnDb,MAAM,CAACc,QAAQ,CAACb,eAAe,CAACS,WAAW,CAACJ,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,CAClE;AAEH,MAAMI,WAAW,GAAGA,CAACJ,MAA6B,EAAES,YAAoB,KACtE,IAAIb,UAAU,CAACc,qBAAqB,CAAC;EACnCC,MAAM,EAAEd,qBAAqB,CAACe,IAAI;EAClCH,YAAY;EACZI,EAAE,EAAEb,MAAM,CAACA,MAAM,CAACc,SAAS,CAACD,EAAE;EAC9BE,UAAU,EAAEf,MAAM,CAACA,MAAM,CAACc,SAAS,CAACC,UAAU,IAAI;CACnD,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"ListCollectionsCursor.js","names":["Data","Effect","F","pipeArguments","Stream","mongoErrorOrDie","MongoError","ListCollectionsCursorImpl","TaggedClass","pipe","arguments","toArray","cursor","promise","catchAllDefect","errorSource","toStream","fromAsyncIterable","identity","catchAll","functionName","CollectionErrorSource","module","name","db","namespace","collection"],"sources":["../../src/ListCollectionsCursor.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAGA,OAAO,KAAKA,IAAI,MAAM,aAAa;AACnC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,CAAC,MAAM,iBAAiB;AAEpC,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,OAAO,KAAKC,MAAM,MAAM,eAAe;AAKvC,SAASC,eAAe,QAAQ,2BAA2B;AAC3D,OAAO,KAAKC,UAAU,MAAM,iBAAiB;AAiB7C;AACA,OAAM,MAAOC,yBAEX,sBAAQP,IAAI,CAACQ,WAAW,CAAC,uBAAuB,CAAiC;EACjFC,IAAIA,CAAA;IACF,OAAON,aAAa,CAAC,IAAI,EAAEO,SAAS,CAAC;EACvC;;AASF,OAAO,MAAMC,OAAO,GAClBC,MAAgC,IAEhCV,CAAC,CAACO,IAAI,CACJR,MAAM,CAACY,OAAO,CAAC,MAAMD,MAAM,CAACA,MAAM,CAACD,OAAO,EAAE,CAAC,EAC7CV,MAAM,CAACa,cAAc,CAACT,eAAe,CAACU,WAAW,CAACH,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,CACvE;AAEH,OAAO,MAAMI,QAAQ,GACnBJ,MAAgC,IAEhCV,CAAC,CAACO,IAAI,CACJL,MAAM,CAACa,iBAAiB,CAACL,MAAM,CAACA,MAAM,EAAEV,CAAC,CAACgB,QAAQ,CAAC,EACnDd,MAAM,CAACe,QAAQ,CAACd,eAAe,CAACU,WAAW,CAACH,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,CAClE;AAEH,MAAMG,WAAW,GAAGA,CAACH,MAA6B,EAAEQ,YAAoB,KACtE,IAAId,UAAU,CAACe,qBAAqB,CAAC;EACnCC,MAAM,EAAEf,yBAAyB,CAACgB,IAAI;EACtCH,YAAY;EACZI,EAAE,EAAEZ,MAAM,CAACA,MAAM,CAACa,SAAS,CAACD,EAAE;EAC9BE,UAAU,EAAEd,MAAM,CAACA,MAAM,CAACa,SAAS,CAACC,UAAU,IAAI;CACnD,CAAC","ignoreList":[]}
@@ -1,16 +1,27 @@
1
1
  /**
2
2
  * @since 0.0.1
3
3
  */
4
+ import * as Data from "effect/Data";
4
5
  import * as Effect from "effect/Effect";
5
6
  import * as F from "effect/Function";
6
7
  import { MongoClient as MongoClient_ } from "mongodb";
8
+ import * as Db from "./Db.js";
7
9
  import { mongoErrorOrDie } from "./internal/mongo-error.js";
8
10
  import * as MongoError from "./MongoError.js";
9
- export const connect = (url, options) => Effect.promise(() => MongoClient_.connect(url, options)).pipe(Effect.catchAllDefect(mongoErrorOrDie(errorSource([new URL(url).host], "connect"))));
10
- export const close = /*#__PURE__*/F.dual(args => isMongoClient(args[0]), (client, force) => Effect.promise(() => client.close(force)).pipe(Effect.catchAllDefect(mongoErrorOrDie(errorSource(client.options.hosts.map(x => x.host ?? "NO_HOST"), "close")))));
11
+ export class MongoClient extends /*#__PURE__*/Data.TaggedClass("MongoClient") {}
12
+ export const connect = (url, options) => Effect.promise(() => MongoClient_.connect(url, options)).pipe(Effect.map(client => new MongoClient({
13
+ client
14
+ })), Effect.catchAllDefect(mongoErrorOrDie(errorSource([new URL(url).host], "connect"))));
15
+ export const close = /*#__PURE__*/F.dual(args => isMongoClient(args[0]), ({
16
+ client
17
+ }, force) => Effect.promise(() => client.close(force)).pipe(Effect.catchAllDefect(mongoErrorOrDie(errorSource(client.options.hosts.map(x => x.host ?? "NO_HOST"), "close")))));
11
18
  export const connectScoped = (url, options) => Effect.acquireRelease(connect(url, options), client => close(client, options?.forceClose).pipe(Effect.orDie));
12
- export const db = /*#__PURE__*/F.dual(args => isMongoClient(args[0]), (client, dbName, options) => client.db(dbName, options));
13
- const isMongoClient = x => x instanceof MongoClient_;
19
+ export const db = /*#__PURE__*/F.dual(args => isMongoClient(args[0]), ({
20
+ client
21
+ }, dbName, options) => new Db.Db({
22
+ db: client.db(dbName, options)
23
+ }));
24
+ const isMongoClient = x => x instanceof MongoClient;
14
25
  const errorSource = (hosts, functionName) => new MongoError.ClientErrorSource({
15
26
  module: "MongoClient",
16
27
  functionName,
@@ -1 +1 @@
1
- {"version":3,"file":"MongoClient.js","names":["Effect","F","MongoClient","MongoClient_","mongoErrorOrDie","MongoError","connect","url","options","promise","pipe","catchAllDefect","errorSource","URL","host","close","dual","args","isMongoClient","client","force","hosts","map","x","connectScoped","acquireRelease","forceClose","orDie","db","dbName","functionName","ClientErrorSource","module"],"sources":["../../src/MongoClient.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAGA,OAAO,KAAKA,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,CAAC,MAAM,iBAAiB;AAGpC,SAASC,WAAW,IAAIC,YAAY,QAAQ,SAAS;AACrD,SAASC,eAAe,QAAQ,2BAA2B;AAC3D,OAAO,KAAKC,UAAU,MAAM,iBAAiB;AAI7C,OAAO,MAAMC,OAAO,GAAGA,CACrBC,GAAW,EACXC,OAA4B,KAE5BR,MAAM,CAACS,OAAO,CAAC,MAAMN,YAAY,CAACG,OAAO,CAACC,GAAG,EAAEC,OAAO,CAAC,CAAC,CAACE,IAAI,CAC3DV,MAAM,CAACW,cAAc,CAACP,eAAe,CAACQ,WAAW,CAAC,CAAC,IAAIC,GAAG,CAACN,GAAG,CAAC,CAACO,IAAI,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CACpF;AAEH,OAAO,MAAMC,KAAK,gBAGdd,CAAC,CAACe,IAAI,CACPC,IAAI,IAAKC,aAAa,CAACD,IAAI,CAAC,CAAC,CAAC,CAAC,EAChC,CAACE,MAAmB,EAAEC,KAAe,KACnCpB,MAAM,CAACS,OAAO,CAAC,MAAMU,MAAM,CAACJ,KAAK,CAACK,KAAK,CAAC,CAAC,CAACV,IAAI,CAC5CV,MAAM,CAACW,cAAc,CAACP,eAAe,CAACQ,WAAW,CAACO,MAAM,CAACX,OAAO,CAACa,KAAK,CAACC,GAAG,CAAEC,CAAC,IAAKA,CAAC,CAACT,IAAI,IAAI,SAAS,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CACnH,CACJ;AAED,OAAO,MAAMU,aAAa,GAAGA,CAC3BjB,GAAW,EACXC,OAAuD,KAEvDR,MAAM,CAACyB,cAAc,CACnBnB,OAAO,CAACC,GAAG,EAAEC,OAAO,CAAC,EACpBW,MAAM,IAAKJ,KAAK,CAACI,MAAM,EAAEX,OAAO,EAAEkB,UAAU,CAAC,CAAChB,IAAI,CAACV,MAAM,CAAC2B,KAAK,CAAC,CAClE;AAEH,OAAO,MAAMC,EAAE,gBAGX3B,CAAC,CAACe,IAAI,CACPC,IAAI,IAAKC,aAAa,CAACD,IAAI,CAAC,CAAC,CAAC,CAAC,EAChC,CAACE,MAAmB,EAAEU,MAAe,EAAErB,OAAmB,KAASW,MAAM,CAACS,EAAE,CAACC,MAAM,EAAErB,OAAO,CAAC,CAC9F;AAED,MAAMU,aAAa,GAAIK,CAAU,IAAKA,CAAC,YAAYpB,YAAY;AAE/D,MAAMS,WAAW,GAAGA,CAACS,KAAoB,EAAES,YAAoB,KAC7D,IAAIzB,UAAU,CAAC0B,iBAAiB,CAAC;EAAEC,MAAM,EAAE,aAAa;EAAEF,YAAY;EAAET;AAAK,CAAE,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"MongoClient.js","names":["Data","Effect","F","MongoClient","MongoClient_","Db","mongoErrorOrDie","MongoError","TaggedClass","connect","url","options","promise","pipe","map","client","catchAllDefect","errorSource","URL","host","close","dual","args","isMongoClient","force","hosts","x","connectScoped","acquireRelease","forceClose","orDie","db","dbName","functionName","ClientErrorSource","module"],"sources":["../../src/MongoClient.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAGA,OAAO,KAAKA,IAAI,MAAM,aAAa;AACnC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,CAAC,MAAM,iBAAiB;AAGpC,SAASC,WAAW,IAAIC,YAAY,QAAQ,SAAS;AACrD,OAAO,KAAKC,EAAE,MAAM,SAAS;AAC7B,SAASC,eAAe,QAAQ,2BAA2B;AAC3D,OAAO,KAAKC,UAAU,MAAM,iBAAiB;AAE7C,OAAM,MAAOJ,WAAY,sBAAQH,IAAI,CAACQ,WAAW,CAAC,aAAa,CAA2B;AAE1F,OAAO,MAAMC,OAAO,GAAGA,CACrBC,GAAW,EACXC,OAA4B,KAE5BV,MAAM,CAACW,OAAO,CAAC,MAAMR,YAAY,CAACK,OAAO,CAACC,GAAG,EAAEC,OAAO,CAAC,CAAC,CAACE,IAAI,CAC3DZ,MAAM,CAACa,GAAG,CAAEC,MAAM,IAAK,IAAIZ,WAAW,CAAC;EAAEY;AAAM,CAAE,CAAC,CAAC,EACnDd,MAAM,CAACe,cAAc,CAACV,eAAe,CAACW,WAAW,CAAC,CAAC,IAAIC,GAAG,CAACR,GAAG,CAAC,CAACS,IAAI,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CACpF;AAEH,OAAO,MAAMC,KAAK,gBAGdlB,CAAC,CAACmB,IAAI,CACPC,IAAI,IAAKC,aAAa,CAACD,IAAI,CAAC,CAAC,CAAC,CAAC,EAChC,CAAC;EAAEP;AAAM,CAAe,EAAES,KAAe,KACvCvB,MAAM,CAACW,OAAO,CAAC,MAAMG,MAAM,CAACK,KAAK,CAACI,KAAK,CAAC,CAAC,CAACX,IAAI,CAC5CZ,MAAM,CAACe,cAAc,CAACV,eAAe,CAACW,WAAW,CAACF,MAAM,CAACJ,OAAO,CAACc,KAAK,CAACX,GAAG,CAAEY,CAAC,IAAKA,CAAC,CAACP,IAAI,IAAI,SAAS,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CACnH,CACJ;AAID,OAAO,MAAMQ,aAAa,GAAGA,CAC3BjB,GAAW,EACXC,OAAkC,KAElCV,MAAM,CAAC2B,cAAc,CACnBnB,OAAO,CAACC,GAAG,EAAEC,OAAO,CAAC,EACpBI,MAAM,IAAKK,KAAK,CAACL,MAAM,EAAEJ,OAAO,EAAEkB,UAAU,CAAC,CAAChB,IAAI,CAACZ,MAAM,CAAC6B,KAAK,CAAC,CAClE;AAEH,OAAO,MAAMC,EAAE,gBAGX7B,CAAC,CAACmB,IAAI,CACPC,IAAI,IAAKC,aAAa,CAACD,IAAI,CAAC,CAAC,CAAC,CAAC,EAChC,CAAC;EAAEP;AAAM,CAAe,EAAEiB,MAAe,EAAErB,OAAmB,KAC5D,IAAIN,EAAE,CAACA,EAAE,CAAC;EAAE0B,EAAE,EAAEhB,MAAM,CAACgB,EAAE,CAACC,MAAM,EAAErB,OAAO;AAAC,CAAE,CAAC,CAChD;AAED,MAAMY,aAAa,GAAIG,CAAU,IAAKA,CAAC,YAAYvB,WAAW;AAE9D,MAAMc,WAAW,GAAGA,CAACQ,KAAoB,EAAEQ,YAAoB,KAC7D,IAAI1B,UAAU,CAAC2B,iBAAiB,CAAC;EAAEC,MAAM,EAAE,aAAa;EAAEF,YAAY;EAAER;AAAK,CAAE,CAAC","ignoreList":[]}
@@ -2,9 +2,9 @@ import * as Effect from "effect/Effect";
2
2
  import * as O from "effect/Option";
3
3
  import * as Schema from "effect/Schema";
4
4
  // TODO: there is probably a Schema to do this decode or using typeclass package for traverse
5
- export const decodeNullableDocument = (schema, value) => Effect.gen(function* (_) {
5
+ export const decodeNullableDocument = (schema, value) => Effect.gen(function* () {
6
6
  if (value === null) return O.none();
7
- const decoded = yield* _(Schema.decodeUnknown(schema)(value));
7
+ const decoded = yield* Schema.decodeUnknown(schema)(value);
8
8
  return O.some(decoded);
9
9
  });
10
10
  //# sourceMappingURL=schema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","names":["Effect","O","Schema","decodeNullableDocument","schema","value","gen","_","none","decoded","decodeUnknown","some"],"sources":["../../../src/internal/schema.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,KAAKA,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,CAAC,MAAM,eAAe;AAClC,OAAO,KAAKC,MAAM,MAAM,eAAe;AAGvC;AACA,OAAO,MAAMC,sBAAsB,GAAGA,CAAUC,MAA8B,EAAEC,KAAsB,KACpGL,MAAM,CAACM,GAAG,CAAC,WAAUC,CAAC;EACpB,IAAIF,KAAK,KAAK,IAAI,EAAE,OAAOJ,CAAC,CAACO,IAAI,EAAE;EACnC,MAAMC,OAAO,GAAG,OAAOF,CAAC,CAACL,MAAM,CAACQ,aAAa,CAACN,MAAM,CAAC,CAACC,KAAK,CAAC,CAAC;EAC7D,OAAOJ,CAAC,CAACU,IAAI,CAACF,OAAO,CAAC;AACxB,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"schema.js","names":["Effect","O","Schema","decodeNullableDocument","schema","value","gen","none","decoded","decodeUnknown","some"],"sources":["../../../src/internal/schema.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,KAAKA,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,CAAC,MAAM,eAAe;AAClC,OAAO,KAAKC,MAAM,MAAM,eAAe;AAGvC;AACA,OAAO,MAAMC,sBAAsB,GAAGA,CAAUC,MAA8B,EAAEC,KAAsB,KACpGL,MAAM,CAACM,GAAG,CAAC,aAAS;EAClB,IAAID,KAAK,KAAK,IAAI,EAAE,OAAOJ,CAAC,CAACM,IAAI,EAAE;EACnC,MAAMC,OAAO,GAAG,OAAON,MAAM,CAACO,aAAa,CAACL,MAAM,CAAC,CAACC,KAAK,CAAC;EAC1D,OAAOJ,CAAC,CAACS,IAAI,CAACF,OAAO,CAAC;AACxB,CAAC,CAAC","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- let moduleVersion = "0.1.3";
1
+ let moduleVersion = "0.2.0";
2
2
  export const getCurrentVersion = () => moduleVersion;
3
3
  export const setCurrentVersion = version => {
4
4
  moduleVersion = version;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "effect-mongodb",
3
- "version": "0.1.3",
3
+ "version": "0.2.0",
4
4
  "description": "A MongoDB toolkit for Effect",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -5,15 +5,31 @@ import * as Data from "effect/Data"
5
5
  import * as Effect from "effect/Effect"
6
6
  import * as F from "effect/Function"
7
7
  import type * as ParseResult from "effect/ParseResult"
8
+ import type { Pipeable } from "effect/Pipeable"
9
+ import { pipeArguments } from "effect/Pipeable"
8
10
  import * as Schema from "effect/Schema"
9
11
  import * as Stream from "effect/Stream"
10
12
  import type { AggregationCursor as MongoAggregationCursor } from "mongodb"
11
13
  import { mongoErrorOrDie } from "./internal/mongo-error.js"
12
14
  import * as MongoError from "./MongoError.js"
13
15
 
14
- export class AggregationCursor<A, I = A, R = never> extends Data.TaggedClass("AggregationCursor")<
15
- { cursor: MongoAggregationCursor<unknown>; schema: Schema.Schema<A, I, R> }
16
- > {
16
+ interface AggregationCursorFields<A, I = A, R = never> {
17
+ cursor: MongoAggregationCursor<unknown>
18
+ schema: Schema.Schema<A, I, R>
19
+ }
20
+
21
+ export interface AggregationCursor<A, I = A, R = never> extends AggregationCursorFields<A, I, R>, Pipeable {
22
+ _tag: "AggregationCursor"
23
+ }
24
+
25
+ /** @internal */
26
+ export class AggregationCursorImpl<A, I = A, R = never>
27
+ extends Data.TaggedClass("AggregationCursor")<AggregationCursorFields<A, I, R>>
28
+ implements AggregationCursor<A, I, R>
29
+ {
30
+ pipe() {
31
+ return pipeArguments(this, arguments)
32
+ }
17
33
  }
18
34
 
19
35
  export const toArray = <A, I, R>(
@@ -39,7 +55,7 @@ export const toStream = <A, I, R>(
39
55
 
40
56
  const errorSource = <A, I, R>(cursor: AggregationCursor<A, I, R>, functionName: string) =>
41
57
  new MongoError.CollectionErrorSource({
42
- module: AggregationCursor.name,
58
+ module: AggregationCursorImpl.name,
43
59
  functionName,
44
60
  db: cursor.cursor.namespace.db,
45
61
  collection: cursor.cursor.namespace.collection ?? "NO_COLLECTION_NAME"
package/src/Collection.ts CHANGED
@@ -7,6 +7,8 @@ import * as Effect from "effect/Effect"
7
7
  import * as F from "effect/Function"
8
8
  import type * as O from "effect/Option"
9
9
  import type * as ParseResult from "effect/ParseResult"
10
+ import type { Pipeable } from "effect/Pipeable"
11
+ import { pipeArguments } from "effect/Pipeable"
10
12
  import * as Schema from "effect/Schema"
11
13
  import type {
12
14
  AggregateOptions,
@@ -42,11 +44,28 @@ import { mongoErrorOrDie } from "./internal/mongo-error.js"
42
44
  import * as SchemaExt from "./internal/schema.js"
43
45
  import * as MongoError from "./MongoError.js"
44
46
 
45
- export class Collection<A extends Document, I extends Document = A, R = never> extends Data.TaggedClass("Collection")<{
47
+ type CollectionFields<A extends Document, I extends Document = A, R = never> = {
46
48
  collection: MongoCollection
47
49
  schema: Schema.Schema<A, I, R>
48
- }> {
50
+ }
51
+
52
+ export interface Collection<A extends Document, I extends Document = A, R = never>
53
+ extends CollectionFields<A, I, R>, Pipeable
54
+ {
55
+ _tag: "Collection"
56
+ /** @internal */
57
+ encode: ReturnType<typeof Schema.encode<A, I, R>>
58
+ }
59
+
60
+ /** @internal */
61
+ export class CollectionImpl<A extends Document, I extends Document = A, R = never>
62
+ extends Data.TaggedClass("Collection")<CollectionFields<A, I, R>>
63
+ implements Collection<A, I, R>
64
+ {
49
65
  readonly encode = Schema.encode(this.schema)
66
+ pipe() {
67
+ return pipeArguments(this, arguments)
68
+ }
50
69
  }
51
70
 
52
71
  export type FindOptions = Omit<MongoFindOptions, "projection">
@@ -68,7 +87,7 @@ export const find: {
68
87
  filter?: Filter<I>,
69
88
  options?: FindOptions
70
89
  ): FindCursor.FindCursor<A, I, R> =>
71
- new FindCursor.FindCursor<A, I, R>({
90
+ new FindCursor.FindCursorImpl<A, I, R>({
72
91
  cursor: collection.collection.find(filter ?? {}, options),
73
92
  schema: collection.schema
74
93
  })
@@ -90,9 +109,9 @@ export const findOne: {
90
109
  filter: Filter<I>,
91
110
  options?: FindOptions
92
111
  ): Effect.Effect<O.Option<A>, MongoError.MongoError | ParseResult.ParseError, R> =>
93
- Effect.gen(function*(_) {
94
- const value = yield* _(Effect.promise(() => collection.collection.findOne(filter, options)))
95
- return yield* _(SchemaExt.decodeNullableDocument(collection.schema, value))
112
+ Effect.gen(function*() {
113
+ const value = yield* Effect.promise(() => collection.collection.findOne(filter, options))
114
+ return yield* SchemaExt.decodeNullableDocument(collection.schema, value)
96
115
  }).pipe(
97
116
  Effect.catchAllDefect(mongoErrorOrDie(errorSource(collection, "findOne")))
98
117
  )
@@ -306,13 +325,13 @@ export const findOneAndReplace: {
306
325
  Effect.promise(() => collection.collection.findOneAndReplace(filter, replacement, options ?? {}))
307
326
  ),
308
327
  Effect.flatMap((value) =>
309
- Effect.gen(function*(_) {
328
+ Effect.gen(function*() {
310
329
  if (options?.includeResultMetadata && !!value) {
311
330
  const result = value as unknown as MongoModifyResult<I>
312
- const maybeValue = yield* _(SchemaExt.decodeNullableDocument(collection.schema, result.value))
331
+ const maybeValue = yield* SchemaExt.decodeNullableDocument(collection.schema, result.value)
313
332
  return { ...result, value: maybeValue }
314
333
  }
315
- return yield* _(SchemaExt.decodeNullableDocument(collection.schema, value))
334
+ return yield* SchemaExt.decodeNullableDocument(collection.schema, value)
316
335
  })
317
336
  ),
318
337
  Effect.catchAllDefect(
@@ -339,7 +358,9 @@ export const rename: {
339
358
  ): Effect.Effect<Collection<A, I, R>, MongoError.MongoError, R> =>
340
359
  F.pipe(
341
360
  Effect.promise(() => collection.collection.rename(newName, options)),
342
- Effect.map((newCollection) => new Collection<A, I, R>({ collection: newCollection, schema: collection.schema })),
361
+ Effect.map((newCollection) =>
362
+ new CollectionImpl<A, I, R>({ collection: newCollection, schema: collection.schema })
363
+ ),
343
364
  Effect.catchAllDefect(mongoErrorOrDie(errorSource(collection, "rename")))
344
365
  )
345
366
  )
@@ -455,7 +476,7 @@ export const aggregate: {
455
476
  pipeline: ReadonlyArray<Document>,
456
477
  options?: AggregateOptions
457
478
  ): AggregationCursor.AggregationCursor<B, BI, BR> =>
458
- new AggregationCursor.AggregationCursor<B, BI, BR>({
479
+ new AggregationCursor.AggregationCursorImpl<B, BI, BR>({
459
480
  cursor: collection.collection.aggregate([...pipeline], options),
460
481
  schema
461
482
  })
@@ -503,14 +524,14 @@ export const countDocuments: {
503
524
  )
504
525
  )
505
526
 
506
- const isCollection = (x: unknown) => x instanceof Collection
527
+ const isCollection = (x: unknown) => x instanceof CollectionImpl
507
528
 
508
529
  const errorSource = <A extends Document, I extends Document = A, R = never>(
509
530
  collection: Collection<A, I, R>,
510
531
  functionName: string
511
532
  ) =>
512
533
  new MongoError.CollectionErrorSource({
513
- module: Collection.name,
534
+ module: CollectionImpl.name,
514
535
  functionName,
515
536
  db: collection.collection.dbName,
516
537
  collection: collection.collection.collectionName
package/src/Db.ts CHANGED
@@ -1,25 +1,27 @@
1
1
  /**
2
2
  * @since 0.0.1
3
3
  */
4
+ import * as Data from "effect/Data"
4
5
  import * as Effect from "effect/Effect"
5
6
  import * as F from "effect/Function"
6
7
  import type * as Schema from "effect/Schema"
7
- import type { Document, DropCollectionOptions, ListCollectionsOptions } from "mongodb"
8
- import { Db } from "mongodb"
8
+ import type { Db as Db_, Document, DropCollectionOptions, ListCollectionsOptions } from "mongodb"
9
9
  import type * as Collection from "./Collection.js"
10
10
  import * as DocumentCollection from "./DocumentCollection.js"
11
11
  import { mongoErrorOrDie } from "./internal/mongo-error.js"
12
12
  import * as ListCollectionsCursor from "./ListCollectionsCursor.js"
13
13
  import * as MongoError from "./MongoError.js"
14
14
 
15
+ export class Db extends Data.TaggedClass("Db")<{ db: Db_ }> {}
16
+
15
17
  export const documentCollection: {
16
18
  (name: string): (db: Db) => DocumentCollection.DocumentCollection
17
19
  (db: Db, name: string): DocumentCollection.DocumentCollection
18
20
  } = F.dual(
19
21
  (args) => isDb(args[0]),
20
22
  (db: Db, name: string): DocumentCollection.DocumentCollection =>
21
- new DocumentCollection.DocumentCollection({
22
- collection: db.collection(name)
23
+ new DocumentCollection.DocumentCollectionImpl({
24
+ collection: db.db.collection(name)
23
25
  })
24
26
  )
25
27
 
@@ -67,7 +69,7 @@ export const listCollections: {
67
69
  } = F.dual(
68
70
  (args) => isDb(args[0]),
69
71
  (db: Db, filter?: Document, options?: ListCollectionsOptions): ListCollectionsCursor.ListCollectionsCursor =>
70
- new ListCollectionsCursor.ListCollectionsCursor({ cursor: db.listCollections(filter, options) })
72
+ new ListCollectionsCursor.ListCollectionsCursorImpl({ cursor: db.db.listCollections(filter, options) })
71
73
  )
72
74
 
73
75
  export const dropCollection: {
@@ -79,7 +81,7 @@ export const dropCollection: {
79
81
  (args) => isDb(args[0]),
80
82
  (db: Db, name: string, options?: DropCollectionOptions): Effect.Effect<boolean, MongoError.MongoError> =>
81
83
  F.pipe(
82
- Effect.promise(() => db.dropCollection(name, options)),
84
+ Effect.promise(() => db.db.dropCollection(name, options)),
83
85
  Effect.catchAllDefect(mongoErrorOrDie(errorSource(db, "dropCollection")))
84
86
  )
85
87
  )
@@ -87,4 +89,4 @@ export const dropCollection: {
87
89
  const isDb = (x: unknown) => x instanceof Db
88
90
 
89
91
  const errorSource = (db: Db, functionName: string) =>
90
- new MongoError.DbErrorSource({ module: "Db", functionName, db: db.databaseName })
92
+ new MongoError.DbErrorSource({ module: "Db", functionName, db: db.db.databaseName })
@@ -4,14 +4,27 @@
4
4
  import * as Data from "effect/Data"
5
5
  import * as Effect from "effect/Effect"
6
6
  import * as F from "effect/Function"
7
+ import type { Pipeable } from "effect/Pipeable"
8
+ import { pipeArguments } from "effect/Pipeable"
7
9
  import * as Stream from "effect/Stream"
8
10
  import type { AggregationCursor as MongoAggregationCursor, Document } from "mongodb"
9
11
  import { mongoErrorOrDie } from "./internal/mongo-error.js"
10
12
  import * as MongoError from "./MongoError.js"
11
13
 
12
- export class DocumentAggregationCursor
13
- extends Data.TaggedClass("DocumentAggregationCursor")<{ cursor: MongoAggregationCursor<Document> }>
14
+ type DocumentAggregationCursorFields = { cursor: MongoAggregationCursor<Document> }
15
+
16
+ export interface DocumentAggregationCursor extends DocumentAggregationCursorFields, Pipeable {
17
+ _tag: "DocumentAggregationCursor"
18
+ }
19
+
20
+ /** @internal */
21
+ export class DocumentAggregationCursorImpl
22
+ extends Data.TaggedClass("DocumentAggregationCursor")<DocumentAggregationCursorFields>
23
+ implements DocumentAggregationCursor
14
24
  {
25
+ pipe() {
26
+ return pipeArguments(this, arguments)
27
+ }
15
28
  }
16
29
 
17
30
  export const toArray = (
@@ -32,7 +45,7 @@ export const toStream = (
32
45
 
33
46
  const errorSource = (cursor: DocumentAggregationCursor, functionName: string) =>
34
47
  new MongoError.CollectionErrorSource({
35
- module: DocumentAggregationCursor.name,
48
+ module: DocumentAggregationCursorImpl.name,
36
49
  functionName,
37
50
  db: cursor.cursor.namespace.db,
38
51
  collection: cursor.cursor.namespace.collection ?? "NO_COLLECTION_NAME"
@@ -6,6 +6,8 @@ import * as Data from "effect/Data"
6
6
  import * as Effect from "effect/Effect"
7
7
  import * as F from "effect/Function"
8
8
  import * as O from "effect/Option"
9
+ import type { Pipeable } from "effect/Pipeable"
10
+ import { pipeArguments } from "effect/Pipeable"
9
11
  import type * as Schema from "effect/Schema"
10
12
  import type {
11
13
  AggregateOptions,
@@ -43,9 +45,21 @@ import type { ModifyResult } from "./internal/modify-result.js"
43
45
  import { mongoErrorOrDie } from "./internal/mongo-error.js"
44
46
  import * as MongoError from "./MongoError.js"
45
47
 
46
- export class DocumentCollection extends Data.TaggedClass("DocumentCollection")<{
48
+ type DocumentCollectionFields = {
47
49
  collection: MongoCollection
48
- }> {
50
+ }
51
+
52
+ export interface DocumentCollection extends DocumentCollectionFields, Pipeable {
53
+ _tag: "DocumentCollection"
54
+ }
55
+
56
+ /** @internal */
57
+ export class DocumentCollectionImpl extends Data.TaggedClass("DocumentCollection")<DocumentCollectionFields>
58
+ implements DocumentCollection
59
+ {
60
+ pipe() {
61
+ return pipeArguments(this, arguments)
62
+ }
49
63
  }
50
64
 
51
65
  export const find: {
@@ -61,7 +75,7 @@ export const find: {
61
75
  } = F.dual(
62
76
  (args) => isDocumentCollection(args[0]),
63
77
  (collection: DocumentCollection, filter?: Filter<Document>, options?: FindOptions) =>
64
- new DocumentFindCursor.DocumentFindCursor(
78
+ new DocumentFindCursor.DocumentFindCursorImpl(
65
79
  {
66
80
  cursor: collection.collection.find(filter ?? {}, options)
67
81
  }
@@ -327,7 +341,7 @@ export const rename: {
327
341
  ): Effect.Effect<DocumentCollection, MongoError.MongoError> =>
328
342
  F.pipe(
329
343
  Effect.promise(() => collection.collection.rename(newName, options)),
330
- Effect.map((collection) => new DocumentCollection({ collection })),
344
+ Effect.map((collection) => new DocumentCollectionImpl({ collection })),
331
345
  Effect.catchAllDefect(mongoErrorOrDie(errorSource(collection, "rename")))
332
346
  )
333
347
  )
@@ -431,7 +445,7 @@ export const aggregate: {
431
445
  pipeline?: ReadonlyArray<Document>,
432
446
  options?: AggregateOptions
433
447
  ): DocumentAggregationCursor.DocumentAggregationCursor =>
434
- new DocumentAggregationCursor.DocumentAggregationCursor({
448
+ new DocumentAggregationCursor.DocumentAggregationCursorImpl({
435
449
  cursor: collection.collection.aggregate(pipeline ? [...pipeline] : undefined, options)
436
450
  })
437
451
  )
@@ -489,16 +503,17 @@ export const typed: {
489
503
  } = F.dual((args) => isDocumentCollection(args[0]), <A extends Document, I extends Document = A, R = never>(
490
504
  collection: DocumentCollection,
491
505
  schema: Schema.Schema<A, I, R>
492
- ): Collection.Collection<A, I, R> => new Collection.Collection<A, I, R>({ collection: collection.collection, schema }))
506
+ ): Collection.Collection<A, I, R> =>
507
+ new Collection.CollectionImpl<A, I, R>({ collection: collection.collection, schema }))
493
508
 
494
- const isDocumentCollection = (x: unknown) => x instanceof DocumentCollection
509
+ const isDocumentCollection = (x: unknown) => x instanceof DocumentCollectionImpl
495
510
 
496
511
  const errorSource = (
497
512
  collection: DocumentCollection,
498
513
  functionName: string
499
514
  ) =>
500
515
  new MongoError.CollectionErrorSource({
501
- module: DocumentCollection.name,
516
+ module: DocumentCollectionImpl.name,
502
517
  functionName,
503
518
  db: collection.collection.dbName,
504
519
  collection: collection.collection.collectionName