effect-mongodb 0.1.2 → 0.1.4

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 (85) hide show
  1. package/README.md +25 -19
  2. package/dist/cjs/AggregationCursor.js +18 -8
  3. package/dist/cjs/AggregationCursor.js.map +1 -1
  4. package/dist/cjs/Collection.js +40 -29
  5. package/dist/cjs/Collection.js.map +1 -1
  6. package/dist/cjs/Db.js +9 -3
  7. package/dist/cjs/Db.js.map +1 -1
  8. package/dist/cjs/DocumentAggregationCursor.js +18 -8
  9. package/dist/cjs/DocumentAggregationCursor.js.map +1 -1
  10. package/dist/cjs/DocumentCollection.js +36 -24
  11. package/dist/cjs/DocumentCollection.js.map +1 -1
  12. package/dist/cjs/DocumentFindCursor.js +24 -14
  13. package/dist/cjs/DocumentFindCursor.js.map +1 -1
  14. package/dist/cjs/FindCursor.js +25 -18
  15. package/dist/cjs/FindCursor.js.map +1 -1
  16. package/dist/cjs/ListCollectionsCursor.js +18 -8
  17. package/dist/cjs/ListCollectionsCursor.js.map +1 -1
  18. package/dist/cjs/MongoClient.js +8 -2
  19. package/dist/cjs/MongoClient.js.map +1 -1
  20. package/dist/cjs/MongoError.js +7 -18
  21. package/dist/cjs/MongoError.js.map +1 -1
  22. package/dist/cjs/internal/mongo-error.js +27 -0
  23. package/dist/cjs/internal/mongo-error.js.map +1 -0
  24. package/dist/cjs/internal/schema.js +2 -2
  25. package/dist/cjs/internal/schema.js.map +1 -1
  26. package/dist/cjs/internal/version.js +1 -1
  27. package/dist/dts/AggregationCursor.d.ts +5 -5
  28. package/dist/dts/AggregationCursor.d.ts.map +1 -1
  29. package/dist/dts/Collection.d.ts +17 -18
  30. package/dist/dts/Collection.d.ts.map +1 -1
  31. package/dist/dts/Db.d.ts.map +1 -1
  32. package/dist/dts/DocumentAggregationCursor.d.ts +5 -5
  33. package/dist/dts/DocumentAggregationCursor.d.ts.map +1 -1
  34. package/dist/dts/DocumentCollection.d.ts +7 -7
  35. package/dist/dts/DocumentCollection.d.ts.map +1 -1
  36. package/dist/dts/DocumentFindCursor.d.ts +5 -5
  37. package/dist/dts/DocumentFindCursor.d.ts.map +1 -1
  38. package/dist/dts/FindCursor.d.ts +5 -5
  39. package/dist/dts/FindCursor.d.ts.map +1 -1
  40. package/dist/dts/ListCollectionsCursor.d.ts +5 -5
  41. package/dist/dts/ListCollectionsCursor.d.ts.map +1 -1
  42. package/dist/dts/MongoClient.d.ts.map +1 -1
  43. package/dist/dts/MongoError.d.ts +32 -12
  44. package/dist/dts/MongoError.d.ts.map +1 -1
  45. package/dist/dts/internal/mongo-error.d.ts +5 -0
  46. package/dist/dts/internal/mongo-error.d.ts.map +1 -0
  47. package/dist/esm/AggregationCursor.js +16 -6
  48. package/dist/esm/AggregationCursor.js.map +1 -1
  49. package/dist/esm/Collection.js +38 -27
  50. package/dist/esm/Collection.js.map +1 -1
  51. package/dist/esm/Db.js +9 -3
  52. package/dist/esm/Db.js.map +1 -1
  53. package/dist/esm/DocumentAggregationCursor.js +16 -6
  54. package/dist/esm/DocumentAggregationCursor.js.map +1 -1
  55. package/dist/esm/DocumentCollection.js +34 -22
  56. package/dist/esm/DocumentCollection.js.map +1 -1
  57. package/dist/esm/DocumentFindCursor.js +22 -12
  58. package/dist/esm/DocumentFindCursor.js.map +1 -1
  59. package/dist/esm/FindCursor.js +23 -16
  60. package/dist/esm/FindCursor.js.map +1 -1
  61. package/dist/esm/ListCollectionsCursor.js +16 -6
  62. package/dist/esm/ListCollectionsCursor.js.map +1 -1
  63. package/dist/esm/MongoClient.js +8 -2
  64. package/dist/esm/MongoClient.js.map +1 -1
  65. package/dist/esm/MongoError.js +3 -17
  66. package/dist/esm/MongoError.js.map +1 -1
  67. package/dist/esm/internal/mongo-error.js +18 -0
  68. package/dist/esm/internal/mongo-error.js.map +1 -0
  69. package/dist/esm/internal/schema.js +2 -2
  70. package/dist/esm/internal/schema.js.map +1 -1
  71. package/dist/esm/internal/version.js +1 -1
  72. package/package.json +1 -1
  73. package/src/AggregationCursor.ts +31 -6
  74. package/src/Collection.ts +80 -50
  75. package/src/Db.ts +7 -3
  76. package/src/DocumentAggregationCursor.ts +27 -5
  77. package/src/DocumentCollection.ts +52 -27
  78. package/src/DocumentFindCursor.ts +34 -11
  79. package/src/FindCursor.ts +36 -13
  80. package/src/ListCollectionsCursor.ts +31 -7
  81. package/src/MongoClient.ts +6 -2
  82. package/src/MongoError.ts +24 -32
  83. package/src/internal/mongo-error.ts +34 -0
  84. package/src/internal/schema.ts +2 -2
  85. package/src/internal/version.ts +1 -1
package/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # effect-mongodb
2
2
 
3
+ ![NPM Version](https://img.shields.io/npm/v/effect-mongodb?link=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2Feffect-mongodb)
4
+ ![minzipped size](https://badgen.net/bundlephobia/minzip/effect-mongodb)
5
+ ![dependency count](https://badgen.net/bundlephobia/dependency-count/effect-mongodb)
6
+ ![tree shaking support](https://badgen.net/bundlephobia/tree-shaking/effect-mongodb)
7
+
3
8
  A [MongoDB](https://github.com/mongodb/node-mongodb-native) toolkit for [Effect](https://github.com/Effect-TS/effect/).
4
9
 
5
10
  ## Install
@@ -15,12 +20,8 @@ Note that `effect`, and `mongodb` are requested as peer dependencies.
15
20
  Here is a simple example of how to use this package:
16
21
 
17
22
  ```typescript
18
- import * as Collection from "effect-mongodb/Collection"
19
- import * as Db from "effect-mongodb/Db"
20
- import * as FindCursor from "effect-mongodb/FindCursor"
21
- import * as MongoClient from "effect-mongodb/MongoClient"
22
- import * as Effect from "effect/Effect"
23
- import * as Schema from "effect/Schema"
23
+ import { Effect, Schema } from "effect"
24
+ import { Collection, Db, FindCursor, MongoClient } from "effect-mongodb"
24
25
 
25
26
  const Person = Schema.Struct({
26
27
  name: Schema.String,
@@ -28,15 +29,15 @@ const Person = Schema.Struct({
28
29
  birthday: Schema.Date
29
30
  })
30
31
 
31
- const program = Effect.gen(function*(_) {
32
- const client = yield* _(MongoClient.connectScoped("mongodb://localhost:27017"))
32
+ const program = Effect.gen(function*() {
33
+ const client = yield* MongoClient.connectScoped("mongodb://localhost:27017")
33
34
  const db = MongoClient.db(client, "source-db")
34
35
  const sourceCollection = Db.collection(db, "source", Person)
35
36
  const destinationCollection = Db.collection(db, "destination", Person)
36
37
 
37
- const items = yield* _(Collection.find(sourceCollection), FindCursor.toArray)
38
+ const items = yield* Collection.find(sourceCollection).pipe(FindCursor.toArray)
38
39
 
39
- yield* _(Collection.insertMany(destinationCollection, items))
40
+ yield* Collection.insertMany(destinationCollection, items)
40
41
  })
41
42
 
42
43
  await program.pipe(Effect.scoped, Effect.runPromise)
@@ -53,18 +54,23 @@ Here is a list of design decisions made and principles followed while developing
53
54
  1. `Option` is used instead of `null` or `undefined` values.
54
55
  2. Some operation options, which have an impact on the shape of API response, may be replaced with stricter functions
55
56
  (e.g. `projection` in `find` operation).
56
- 3. **Schema-based vs Document-based**: the package provides two sets of functions.
57
-
58
- The first set is based on MongoDB's `Document` type, therefore, without any runtime validation on the shape of the
59
- document, and signatures mostly identical to those of the original APIs.
57
+ 3. **Document-based API**: these API are based on MongoDB's `Document` type, therefore, without any runtime validation
58
+ on the shape of the document.
59
+
60
+ Signatures are mostly identical to those of the original APIs.
61
+
60
62
  All modules belonging to this set are prefixed with `Document`, e.g. `DocumentCollection` or `DocumentFindCursor`.
61
-
62
- The second set is based on Schema, therefore, provides runtime validation.
63
- Its functions may have slightly different signatures than the original APIs, since they enforce stricter types than
64
- the first set.
63
+
64
+ These API are mainly useful for incremental adoption in existing codebases, and to allow quick prototyping when validation is redundant.
65
+ 4. **Schema-based API**: these API are based on Schema, therefore, provides runtime validation.
66
+
67
+ Functions may have slightly different signatures than the original APIs, since they enforce stricter types than
68
+ the Document-based API.
69
+
65
70
  All modules belonging to this set don't have any prefix, e.g. `Collection` or `FindCursor`.
71
+
66
72
  While developing the package, this set of functions is the one we put more effort into.
67
- 4. **Error handling**: we introduced a new error type `MongoError`, derived from
73
+ 5. **Error handling**: we introduced a new error type `MongoError`, derived from
68
74
  [`TaggedError`](https://effect.website/docs/data-types/data/#taggederror), to wrap the original MongoDB errors.
69
75
  The current implementation is basic, but it will be extended to provide more detailed information and a finer error
70
76
  handling.
@@ -3,12 +3,14 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.toStream = exports.toArray = exports.AggregationCursor = void 0;
6
+ exports.toStream = exports.toArray = exports.AggregationCursorImpl = void 0;
7
7
  var Data = _interopRequireWildcard(require("effect/Data"));
8
8
  var Effect = _interopRequireWildcard(require("effect/Effect"));
9
9
  var F = _interopRequireWildcard(require("effect/Function"));
10
+ var _Pipeable = require("effect/Pipeable");
10
11
  var Schema = _interopRequireWildcard(require("effect/Schema"));
11
12
  var Stream = _interopRequireWildcard(require("effect/Stream"));
13
+ var _mongoError = require("./internal/mongo-error.js");
12
14
  var MongoError = _interopRequireWildcard(require("./MongoError.js"));
13
15
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
14
16
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -16,19 +18,27 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
16
18
  * @since 0.0.1
17
19
  */
18
20
 
19
- class AggregationCursor extends /*#__PURE__*/Data.TaggedClass("AggregationCursor") {}
20
- exports.AggregationCursor = AggregationCursor;
21
+ /** @internal */
22
+ class AggregationCursorImpl extends /*#__PURE__*/Data.TaggedClass("AggregationCursor") {
23
+ pipe() {
24
+ return (0, _Pipeable.pipeArguments)(this, arguments);
25
+ }
26
+ }
27
+ exports.AggregationCursorImpl = AggregationCursorImpl;
21
28
  const toArray = cursor => {
22
29
  const decode = Schema.decodeUnknown(cursor.schema);
23
- return Effect.tryPromise({
24
- try: () => cursor.cursor.toArray(),
25
- catch: F.identity
26
- }).pipe(Effect.catchAll(MongoError.mongoErrorDie("Unable to get array from mongodb aggregate cursor")), Effect.flatMap(Effect.forEach(x => decode(x))));
30
+ return Effect.promise(() => cursor.cursor.toArray()).pipe(Effect.catchAllDefect((0, _mongoError.mongoErrorOrDie)(errorSource(cursor, "toArray"))), Effect.flatMap(Effect.forEach(x => decode(x))));
27
31
  };
28
32
  exports.toArray = toArray;
29
33
  const toStream = cursor => {
30
34
  const decode = Schema.decodeUnknown(cursor.schema);
31
- return F.pipe(Stream.fromAsyncIterable(cursor.cursor, F.identity), Stream.catchAll(MongoError.mongoErrorStream("Unable to get stream from mongodb aggregate cursor")), Stream.mapEffect(x => decode(x)));
35
+ return F.pipe(Stream.fromAsyncIterable(cursor.cursor, F.identity), Stream.catchAll((0, _mongoError.mongoErrorOrDie)(errorSource(cursor, "toStream"))), Stream.mapEffect(x => decode(x)));
32
36
  };
33
37
  exports.toStream = toStream;
38
+ const errorSource = (cursor, functionName) => new MongoError.CollectionErrorSource({
39
+ module: AggregationCursorImpl.name,
40
+ functionName,
41
+ db: cursor.cursor.namespace.db,
42
+ collection: cursor.cursor.namespace.collection ?? "NO_COLLECTION_NAME"
43
+ });
34
44
  //# sourceMappingURL=AggregationCursor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AggregationCursor.js","names":["Data","_interopRequireWildcard","require","Effect","F","Schema","Stream","MongoError","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","AggregationCursor","TaggedClass","exports","toArray","cursor","decode","decodeUnknown","schema","tryPromise","try","catch","identity","pipe","catchAll","mongoErrorDie","flatMap","forEach","x","toStream","fromAsyncIterable","mongoErrorStream","mapEffect"],"sources":["../../src/AggregationCursor.ts"],"sourcesContent":[null],"mappings":";;;;;;AAGA,IAAAA,IAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,uBAAA,CAAAC,OAAA;AACA,IAAAE,CAAA,GAAAH,uBAAA,CAAAC,OAAA;AAEA,IAAAG,MAAA,GAAAJ,uBAAA,CAAAC,OAAA;AACA,IAAAI,MAAA,GAAAL,uBAAA,CAAAC,OAAA;AAEA,IAAAK,UAAA,GAAAN,uBAAA,CAAAC,OAAA;AAA6C,SAAAM,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAR,wBAAAQ,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAA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ACmC,QAAQ,CAAClC,UAAU,CAACyC,gBAAgB,CAAI,oDAAoD,CAAC,CAAC,EACrG1C,MAAM,CAAC2C,SAAS,CAAEJ,CAAC,IAAKZ,MAAM,CAACY,CAAC,CAAC,CAAC,CACnC;AACH,CAAC;AAAAf,OAAA,CAAAgB,QAAA,GAAAA,QAAA","ignoreList":[]}
1
+ {"version":3,"file":"AggregationCursor.js","names":["Data","_interopRequireWildcard","require","Effect","F","_Pipeable","Schema","Stream","_mongoError","MongoError","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","AggregationCursorImpl","TaggedClass","pipe","pipeArguments","arguments","toArray","cursor","decode","decodeUnknown","schema","promise","catchAllDefect","mongoErrorOrDie","errorSource","flatMap","forEach","x","exports","toStream","fromAsyncIterable","identity","catchAll","mapEffect","functionName","CollectionErrorSource","module","name","db","namespace","collection"],"sources":["../../src/AggregationCursor.ts"],"sourcesContent":[null],"mappings":";;;;;;AAGA,IAAAA,IAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,uBAAA,CAAAC,OAAA;AACA,IAAAE,CAAA,GAAAH,uBAAA,CAAAC,OAAA;AAGA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAL,uBAAA,CAAAC,OAAA;AACA,IAAAK,MAAA,GAAAN,uBAAA,CAAAC,OAAA;AAEA,IAAAM,WAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAR,uBAAA,CAAAC,OAAA;AAA6C,SAAAQ,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAV,wBAAAU,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF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7B,MAAM,CAACsC,cAAc,CAAC,IAAAC,2BAAe,EAACC,WAAW,CAACP,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,EACtEjC,MAAM,CAACyC,OAAO,CAACzC,MAAM,CAAC0C,OAAO,CAAEC,CAAC,IAAKT,MAAM,CAACS,CAAC,CAAC,CAAC,CAAC,CACjD;AACH,CAAC;AAAAC,OAAA,CAAAZ,OAAA,GAAAA,OAAA;AAEM,MAAMa,QAAQ,GACnBZ,MAAkC,IACqC;EACvE,MAAMC,MAAM,GAAG/B,MAAM,CAACgC,aAAa,CAACF,MAAM,CAACG,MAAM,CAAC;EAClD,OAAOnC,CAAC,CAAC4B,IAAI,CACXzB,MAAM,CAAC0C,iBAAiB,CAACb,MAAM,CAACA,MAAM,EAAEhC,CAAC,CAAC8C,QAAQ,CAAC,EACnD3C,MAAM,CAAC4C,QAAQ,CAAC,IAAAT,2BAAe,EAACC,WAAW,CAACP,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,EACjE7B,MAAM,CAAC6C,SAAS,CAAEN,CAAC,IAAKT,MAAM,CAACS,CAAC,CAAC,CAAC,CACnC;AACH,CAAC;AAAAC,OAAA,CAAAC,QAAA,GAAAA,QAAA;AAED,MAAML,WAAW,GAAGA,CAAUP,MAAkC,EAAEiB,YAAoB,KACpF,IAAI5C,UAAU,CAAC6C,qBAAqB,CAAC;EACnCC,MAAM,EAAEzB,qBAAqB,CAAC0B,IAAI;EAClCH,YAAY;EACZI,EAAE,EAAErB,MAAM,CAACA,MAAM,CAACsB,SAAS,CAACD,EAAE;EAC9BE,UAAU,EAAEvB,MAAM,CAACA,MAAM,CAACsB,SAAS,CAACC,UAAU,IAAI;CACnD,CAAC","ignoreList":[]}
@@ -3,14 +3,16 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.updateMany = exports.replaceOne = exports.rename = exports.insertOne = exports.insertMany = exports.findOneAndReplace = exports.findOne = exports.find = exports.estimatedDocumentCount = exports.dropIndex = exports.drop = exports.deleteOne = exports.deleteMany = exports.createIndexes = exports.createIndex = exports.countDocuments = exports.aggregate = exports.Collection = void 0;
6
+ exports.updateMany = exports.replaceOne = exports.rename = exports.insertOne = exports.insertMany = exports.findOneAndReplace = exports.findOne = exports.find = exports.estimatedDocumentCount = exports.dropIndex = exports.drop = exports.deleteOne = exports.deleteMany = exports.createIndexes = exports.createIndex = exports.countDocuments = exports.aggregate = exports.CollectionImpl = void 0;
7
7
  var Array = _interopRequireWildcard(require("effect/Array"));
8
8
  var Data = _interopRequireWildcard(require("effect/Data"));
9
9
  var Effect = _interopRequireWildcard(require("effect/Effect"));
10
10
  var F = _interopRequireWildcard(require("effect/Function"));
11
+ var _Pipeable = require("effect/Pipeable");
11
12
  var Schema = _interopRequireWildcard(require("effect/Schema"));
12
13
  var AggregationCursor = _interopRequireWildcard(require("./AggregationCursor.js"));
13
14
  var FindCursor = _interopRequireWildcard(require("./FindCursor.js"));
15
+ var _mongoError = require("./internal/mongo-error.js");
14
16
  var SchemaExt = _interopRequireWildcard(require("./internal/schema.js"));
15
17
  var MongoError = _interopRequireWildcard(require("./MongoError.js"));
16
18
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
@@ -19,51 +21,60 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
19
21
  * @since 0.0.1
20
22
  */
21
23
 
22
- class Collection extends /*#__PURE__*/Data.TaggedClass("Collection") {
24
+ /** @internal */
25
+ class CollectionImpl extends /*#__PURE__*/Data.TaggedClass("Collection") {
23
26
  encode = /*#__PURE__*/Schema.encode(this.schema);
27
+ pipe() {
28
+ return (0, _Pipeable.pipeArguments)(this, arguments);
29
+ }
24
30
  }
25
- exports.Collection = Collection;
26
- const find = exports.find = /*#__PURE__*/F.dual(args => isCollection(args[0]), (collection, filter, options) => new FindCursor.FindCursor({
31
+ exports.CollectionImpl = CollectionImpl;
32
+ const find = exports.find = /*#__PURE__*/F.dual(args => isCollection(args[0]), (collection, filter, options) => new FindCursor.FindCursorImpl({
27
33
  cursor: collection.collection.find(filter ?? {}, options),
28
34
  schema: collection.schema
29
35
  }));
30
- const findOne = exports.findOne = /*#__PURE__*/F.dual(args => isCollection(args[0]), (collection, filter, options) => Effect.gen(function* (_) {
31
- const value = yield* _(Effect.promise(() => collection.collection.findOne(filter, options)));
32
- return yield* _(SchemaExt.decodeNullableDocument(collection.schema, value));
33
- }).pipe(Effect.catchAllDefect(MongoError.mongoErrorDie("findOne error"))));
34
- const insertOne = exports.insertOne = /*#__PURE__*/F.dual(args => isCollection(args[0]), (collection, doc, options) => F.pipe(collection.encode(doc), Effect.flatMap(doc => Effect.promise(() => collection.collection.insertOne(doc, options))), Effect.catchAllDefect(MongoError.mongoErrorDie("insertOne error"))));
36
+ const findOne = exports.findOne = /*#__PURE__*/F.dual(args => isCollection(args[0]), (collection, filter, options) => Effect.gen(function* () {
37
+ const value = yield* Effect.promise(() => collection.collection.findOne(filter, options));
38
+ return yield* SchemaExt.decodeNullableDocument(collection.schema, value);
39
+ }).pipe(Effect.catchAllDefect((0, _mongoError.mongoErrorOrDie)(errorSource(collection, "findOne")))));
40
+ const insertOne = exports.insertOne = /*#__PURE__*/F.dual(args => isCollection(args[0]), (collection, doc, options) => F.pipe(collection.encode(doc), Effect.flatMap(doc => Effect.promise(() => collection.collection.insertOne(doc, options))), Effect.catchAllDefect((0, _mongoError.mongoErrorOrDie)(errorSource(collection, "insertOne")))));
35
41
  const insertMany = exports.insertMany = /*#__PURE__*/F.dual(args => isCollection(args[0]), (collection, docs, options) => {
36
- return F.pipe(docs, Effect.forEach(doc => collection.encode(doc)), Effect.flatMap(docs => Effect.promise(() => collection.collection.insertMany(docs, options))), Effect.catchAllDefect(MongoError.mongoErrorDie("insertMany error")));
42
+ return F.pipe(docs, Effect.forEach(doc => collection.encode(doc)), Effect.flatMap(docs => Effect.promise(() => collection.collection.insertMany(docs, options))), Effect.catchAllDefect((0, _mongoError.mongoErrorOrDie)(errorSource(collection, "insertMany"))));
37
43
  });
38
- const deleteOne = exports.deleteOne = /*#__PURE__*/F.dual(args => isCollection(args[0]), (collection, filter, options) => Effect.promise(() => collection.collection.deleteOne(filter, options)).pipe(Effect.catchAllDefect(MongoError.mongoErrorDie("deleteOne error"))));
39
- const deleteMany = exports.deleteMany = /*#__PURE__*/F.dual(args => isCollection(args[0]), (collection, filter, options) => Effect.promise(() => collection.collection.deleteMany(filter, options)).pipe(Effect.catchAllDefect(MongoError.mongoErrorDie("deleteMany error"))));
40
- const updateMany = exports.updateMany = /*#__PURE__*/F.dual(args => isCollection(args[0]), (collection, filter, update, options) => Effect.promise(() => collection.collection.updateMany(filter, Array.isArray(update) ? [...update] : update, options)).pipe(Effect.catchAllDefect(MongoError.mongoErrorDie("updateMany error"))));
41
- const replaceOne = exports.replaceOne = /*#__PURE__*/F.dual(args => isCollection(args[0]), (collection, filter, replacement, options) => F.pipe(collection.encode(replacement), Effect.flatMap(replacement => Effect.promise(() => collection.collection.replaceOne(filter, replacement, options))), Effect.catchAllDefect(MongoError.mongoErrorDie("replaceOne error"))));
42
- const findOneAndReplace = exports.findOneAndReplace = /*#__PURE__*/F.dual(args => isCollection(args[0]), (collection, filter, replacement, options) => F.pipe(collection.encode(replacement), Effect.flatMap(replacement => Effect.promise(() => collection.collection.findOneAndReplace(filter, replacement, options ?? {}))), Effect.flatMap(value => Effect.gen(function* (_) {
44
+ const deleteOne = exports.deleteOne = /*#__PURE__*/F.dual(args => isCollection(args[0]), (collection, filter, options) => Effect.promise(() => collection.collection.deleteOne(filter, options)).pipe(Effect.catchAllDefect((0, _mongoError.mongoErrorOrDie)(errorSource(collection, "deleteOne")))));
45
+ const deleteMany = exports.deleteMany = /*#__PURE__*/F.dual(args => isCollection(args[0]), (collection, filter, options) => Effect.promise(() => collection.collection.deleteMany(filter, options)).pipe(Effect.catchAllDefect((0, _mongoError.mongoErrorOrDie)(errorSource(collection, "deleteMany")))));
46
+ const updateMany = exports.updateMany = /*#__PURE__*/F.dual(args => isCollection(args[0]), (collection, filter, update, options) => Effect.promise(() => collection.collection.updateMany(filter, Array.isArray(update) ? [...update] : update, options)).pipe(Effect.catchAllDefect((0, _mongoError.mongoErrorOrDie)(errorSource(collection, "updateMany")))));
47
+ const replaceOne = exports.replaceOne = /*#__PURE__*/F.dual(args => isCollection(args[0]), (collection, filter, replacement, options) => F.pipe(collection.encode(replacement), Effect.flatMap(replacement => Effect.promise(() => collection.collection.replaceOne(filter, replacement, options))), Effect.catchAllDefect((0, _mongoError.mongoErrorOrDie)(errorSource(collection, "replaceOne")))));
48
+ const findOneAndReplace = exports.findOneAndReplace = /*#__PURE__*/F.dual(args => isCollection(args[0]), (collection, filter, replacement, options) => F.pipe(collection.encode(replacement), Effect.flatMap(replacement => Effect.promise(() => collection.collection.findOneAndReplace(filter, replacement, options ?? {}))), Effect.flatMap(value => Effect.gen(function* () {
43
49
  if (options?.includeResultMetadata && !!value) {
44
50
  const result = value;
45
- const maybeValue = yield* _(SchemaExt.decodeNullableDocument(collection.schema, result.value));
51
+ const maybeValue = yield* SchemaExt.decodeNullableDocument(collection.schema, result.value);
46
52
  return {
47
53
  ...result,
48
54
  value: maybeValue
49
55
  };
50
56
  }
51
- return yield* _(SchemaExt.decodeNullableDocument(collection.schema, value));
52
- })), Effect.catchAllDefect(MongoError.mongoErrorDie("findOneAndReplace error"))));
53
- const rename = exports.rename = /*#__PURE__*/F.dual(args => isCollection(args[0]), (collection, newName, options) => F.pipe(Effect.promise(() => collection.collection.rename(newName, options)), Effect.map(newCollection => new Collection({
57
+ return yield* SchemaExt.decodeNullableDocument(collection.schema, value);
58
+ })), Effect.catchAllDefect((0, _mongoError.mongoErrorOrDie)(errorSource(collection, "findOneAndReplace")))));
59
+ const rename = exports.rename = /*#__PURE__*/F.dual(args => isCollection(args[0]), (collection, newName, options) => F.pipe(Effect.promise(() => collection.collection.rename(newName, options)), Effect.map(newCollection => new CollectionImpl({
54
60
  collection: newCollection,
55
61
  schema: collection.schema
56
- })), Effect.catchAllDefect(MongoError.mongoErrorDie("rename error"))));
57
- const drop = exports.drop = /*#__PURE__*/F.dual(args => isCollection(args[0]), (collection, options) => F.pipe(Effect.promise(() => collection.collection.drop(options)), Effect.catchAllDefect(MongoError.mongoErrorDie("drop error"))));
58
- const createIndexes = exports.createIndexes = /*#__PURE__*/F.dual(args => isCollection(args[0]), (collection, indexSpecs, options) => F.pipe(Effect.promise(() => collection.collection.createIndexes([...indexSpecs], options)), Effect.catchAllDefect(MongoError.mongoErrorDie("createIndexes error"))));
59
- const createIndex = exports.createIndex = /*#__PURE__*/F.dual(args => isCollection(args[0]), (collection, indexSpec, options) => F.pipe(Effect.promise(() => collection.collection.createIndex(indexSpec, options)), Effect.catchAllDefect(MongoError.mongoErrorDie("createIndex error"))));
60
- // TODO: review return type. Should we return Document like mongodb driver?
61
- const dropIndex = exports.dropIndex = /*#__PURE__*/F.dual(args => isCollection(args[0]), (collection, indexName, options) => F.pipe(Effect.promise(() => collection.collection.dropIndex(indexName, options)), Effect.asVoid, Effect.catchAllDefect(MongoError.mongoErrorDie("dropIndex error"))));
62
- const aggregate = exports.aggregate = /*#__PURE__*/F.dual(args => isCollection(args[0]), (collection, pipeline, schema, options) => new AggregationCursor.AggregationCursor({
62
+ })), Effect.catchAllDefect((0, _mongoError.mongoErrorOrDie)(errorSource(collection, "rename")))));
63
+ const drop = exports.drop = /*#__PURE__*/F.dual(args => isCollection(args[0]), (collection, options) => F.pipe(Effect.promise(() => collection.collection.drop(options)), Effect.catchAllDefect((0, _mongoError.mongoErrorOrDie)(errorSource(collection, "drop")))));
64
+ const createIndexes = exports.createIndexes = /*#__PURE__*/F.dual(args => isCollection(args[0]), (collection, indexSpecs, options) => F.pipe(Effect.promise(() => collection.collection.createIndexes([...indexSpecs], options)), Effect.catchAllDefect((0, _mongoError.mongoErrorOrDie)(errorSource(collection, "createIndexes")))));
65
+ const createIndex = exports.createIndex = /*#__PURE__*/F.dual(args => isCollection(args[0]), (collection, indexSpec, options) => F.pipe(Effect.promise(() => collection.collection.createIndex(indexSpec, options)), Effect.catchAllDefect((0, _mongoError.mongoErrorOrDie)(errorSource(collection, "createIndex")))));
66
+ const dropIndex = exports.dropIndex = /*#__PURE__*/F.dual(args => isCollection(args[0]), (collection, indexName, options) => F.pipe(Effect.promise(() => collection.collection.dropIndex(indexName, options)), Effect.catchAllDefect((0, _mongoError.mongoErrorOrDie)(errorSource(collection, "dropIndex")))));
67
+ const aggregate = exports.aggregate = /*#__PURE__*/F.dual(args => isCollection(args[0]), (collection, schema, pipeline, options) => new AggregationCursor.AggregationCursorImpl({
63
68
  cursor: collection.collection.aggregate([...pipeline], options),
64
69
  schema
65
70
  }));
66
- const estimatedDocumentCount = exports.estimatedDocumentCount = /*#__PURE__*/F.dual(args => isCollection(args[0]), (collection, options) => F.pipe(Effect.promise(() => collection.collection.estimatedDocumentCount(options)), Effect.catchAllDefect(MongoError.mongoErrorDie("estimatedDocumentCount error"))));
67
- const countDocuments = exports.countDocuments = /*#__PURE__*/F.dual(args => isCollection(args[0]), (collection, filter, options) => F.pipe(Effect.promise(() => collection.collection.countDocuments(filter, options)), Effect.catchAllDefect(MongoError.mongoErrorDie("countDocuments error"))));
68
- const isCollection = x => x instanceof Collection;
71
+ const estimatedDocumentCount = exports.estimatedDocumentCount = /*#__PURE__*/F.dual(args => isCollection(args[0]), (collection, options) => F.pipe(Effect.promise(() => collection.collection.estimatedDocumentCount(options)), Effect.catchAllDefect((0, _mongoError.mongoErrorOrDie)(errorSource(collection, "estimatedDocumentCount")))));
72
+ const countDocuments = exports.countDocuments = /*#__PURE__*/F.dual(args => isCollection(args[0]), (collection, filter, options) => F.pipe(Effect.promise(() => collection.collection.countDocuments(filter, options)), Effect.catchAllDefect((0, _mongoError.mongoErrorOrDie)(errorSource(collection, "countDocuments")))));
73
+ const isCollection = x => x instanceof CollectionImpl;
74
+ const errorSource = (collection, functionName) => new MongoError.CollectionErrorSource({
75
+ module: CollectionImpl.name,
76
+ functionName,
77
+ db: collection.collection.dbName,
78
+ collection: collection.collection.collectionName
79
+ });
69
80
  //# sourceMappingURL=Collection.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Collection.js","names":["Array","_interopRequireWildcard","require","Data","Effect","F","Schema","AggregationCursor","FindCursor","SchemaExt","MongoError","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","Collection","TaggedClass","encode","schema","find","exports","dual","args","isCollection","collection","filter","options","cursor","findOne","gen","_","value","promise","decodeNullableDocument","pipe","catchAllDefect","mongoErrorDie","insertOne","doc","flatMap","insertMany","docs","forEach","deleteOne","deleteMany","updateMany","update","isArray","replaceOne","replacement","findOneAndReplace","includeResultMetadata","result","maybeValue","rename","newName","map","newCollection","drop","createIndexes","indexSpecs","createIndex","indexSpec","dropIndex","indexName","asVoid","aggregate","pipeline","estimatedDocumentCount","countDocuments","x"],"sources":["../../src/Collection.ts"],"sourcesContent":[null],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAF,uBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAH,uBAAA,CAAAC,OAAA;AACA,IAAAG,CAAA,GAAAJ,uBAAA,CAAAC,OAAA;AAGA,IAAAI,MAAA,GAAAL,uBAAA,CAAAC,OAAA;AA2BA,IAAAK,iBAAA,GAAAN,uBAAA,CAAAC,OAAA;AACA,IAAAM,UAAA,GAAAP,uBAAA,CAAAC,OAAA;AAGA,IAAAO,SAAA,GAAAR,uBAAA,CAAAC,OAAA;AACA,IAAAQ,UAAA,GAAAT,uBAAA,CAAAC,OAAA;AAA6C,SAAAS,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAA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names":["Array","_interopRequireWildcard","require","Data","Effect","F","_Pipeable","Schema","AggregationCursor","FindCursor","_mongoError","SchemaExt","MongoError","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","CollectionImpl","TaggedClass","encode","schema","pipe","pipeArguments","arguments","find","exports","dual","args","isCollection","collection","filter","options","FindCursorImpl","cursor","findOne","gen","value","promise","decodeNullableDocument","catchAllDefect","mongoErrorOrDie","errorSource","insertOne","doc","flatMap","insertMany","docs","forEach","deleteOne","deleteMany","updateMany","update","isArray","replaceOne","replacement","findOneAndReplace","includeResultMetadata","result","maybeValue","rename","newName","map","newCollection","drop","createIndexes","indexSpecs","createIndex","indexSpec","dropIndex","indexName","aggregate","pipeline","AggregationCursorImpl","estimatedDocumentCount","countDocuments","x","functionName","CollectionErrorSource","module","name","db","dbName","collectionName"],"sources":["../../src/Collection.ts"],"sourcesContent":[null],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAF,uBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAH,uBAAA,CAAAC,OAAA;AACA,IAAAG,CAAA,GAAAJ,uBAAA,CAAAC,OAAA;AAIA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAN,uBAAA,CAAAC,OAAA;AA2BA,IAAAM,iBAAA,GAAAP,uBAAA,CAAAC,OAAA;AACA,IAAAO,UAAA,GAAAR,uBAAA,CAAAC,OAAA;AAGA,IAAAQ,WAAA,GAAAR,OAAA;AACA,IAAAS,SAAA,GAAAV,uBAAA,CAAAC,OAAA;AACA,IAAAU,UAAA,GAAAX,uBAAA,CAAAC,OAAA;AAA6C,SAAAW,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,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5C,MAAM,EAAEC,OAAO,CAAC,CAAC,EAC3E3C,MAAM,CAACmD,cAAc,CAAC,IAAAC,2BAAe,EAACC,WAAW,CAACZ,UAAU,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAClF,CACJ;AAED,MAAMD,YAAY,GAAI+C,CAAU,IAAKA,CAAC,YAAY1D,cAAc;AAEhE,MAAMwB,WAAW,GAAGA,CAClBZ,UAA+B,EAC/B+C,YAAoB,KAEpB,IAAIhF,UAAU,CAACiF,qBAAqB,CAAC;EACnCC,MAAM,EAAE7D,cAAc,CAAC8D,IAAI;EAC3BH,YAAY;EACZI,EAAE,EAAEnD,UAAU,CAACA,UAAU,CAACoD,MAAM;EAChCpD,UAAU,EAAEA,UAAU,CAACA,UAAU,CAACqD;CACnC,CAAC","ignoreList":[]}
package/dist/cjs/Db.js CHANGED
@@ -8,6 +8,7 @@ var Effect = _interopRequireWildcard(require("effect/Effect"));
8
8
  var F = _interopRequireWildcard(require("effect/Function"));
9
9
  var _mongodb = require("mongodb");
10
10
  var DocumentCollection = _interopRequireWildcard(require("./DocumentCollection.js"));
11
+ var _mongoError = require("./internal/mongo-error.js");
11
12
  var ListCollectionsCursor = _interopRequireWildcard(require("./ListCollectionsCursor.js"));
12
13
  var MongoError = _interopRequireWildcard(require("./MongoError.js"));
13
14
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
@@ -16,13 +17,18 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
16
17
  * @since 0.0.1
17
18
  */
18
19
 
19
- const documentCollection = exports.documentCollection = /*#__PURE__*/F.dual(args => isDb(args[0]), (db, name) => new DocumentCollection.DocumentCollection({
20
+ const documentCollection = exports.documentCollection = /*#__PURE__*/F.dual(args => isDb(args[0]), (db, name) => new DocumentCollection.DocumentCollectionImpl({
20
21
  collection: db.collection(name)
21
22
  }));
22
23
  const collection = exports.collection = /*#__PURE__*/F.dual(args => isDb(args[0]), (db, name, schema) => DocumentCollection.typed(documentCollection(db, name), schema));
23
- const listCollections = exports.listCollections = /*#__PURE__*/F.dual(args => isDb(args[0]), (db, filter, options) => new ListCollectionsCursor.ListCollectionsCursor({
24
+ const listCollections = exports.listCollections = /*#__PURE__*/F.dual(args => isDb(args[0]), (db, filter, options) => new ListCollectionsCursor.ListCollectionsCursorImpl({
24
25
  cursor: db.listCollections(filter, options)
25
26
  }));
26
- const dropCollection = exports.dropCollection = /*#__PURE__*/F.dual(args => isDb(args[0]), (db, name, options) => F.pipe(Effect.promise(() => db.dropCollection(name, options)), Effect.catchAllDefect(MongoError.mongoErrorDie("dropCollection error"))));
27
+ const dropCollection = exports.dropCollection = /*#__PURE__*/F.dual(args => isDb(args[0]), (db, name, options) => F.pipe(Effect.promise(() => db.dropCollection(name, options)), Effect.catchAllDefect((0, _mongoError.mongoErrorOrDie)(errorSource(db, "dropCollection")))));
27
28
  const isDb = x => x instanceof _mongodb.Db;
29
+ const errorSource = (db, functionName) => new MongoError.DbErrorSource({
30
+ module: "Db",
31
+ functionName,
32
+ db: db.databaseName
33
+ });
28
34
  //# sourceMappingURL=Db.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Db.js","names":["Effect","_interopRequireWildcard","require","F","_mongodb","DocumentCollection","ListCollectionsCursor","MongoError","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","documentCollection","exports","dual","args","isDb","db","name","collection","schema","typed","listCollections","filter","options","cursor","dropCollection","pipe","promise","catchAllDefect","mongoErrorDie","x","Db"],"sources":["../../src/Db.ts"],"sourcesContent":[null],"mappings":";;;;;;AAGA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,CAAA,GAAAF,uBAAA,CAAAC,OAAA;AAGA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAAG,kBAAA,G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BAAsB,CAAC,CAAC,CACjF,CACJ;AAED,MAAMd,IAAI,GAAIe,CAAU,IAAKA,CAAC,YAAYC,WAAE","ignoreList":[]}
1
+ {"version":3,"file":"Db.js","names":["Effect","_interopRequireWildcard","require","F","_mongodb","DocumentCollection","_mongoError","ListCollectionsCursor","MongoError","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","documentCollection","exports","dual","args","isDb","db","name","DocumentCollectionImpl","collection","schema","typed","listCollections","filter","options","ListCollectionsCursorImpl","cursor","dropCollection","pipe","promise","catchAllDefect","mongoErrorOrDie","errorSource","x","Db","functionName","DbErrorSource","module","databaseName"],"sources":["../../src/Db.ts"],"sourcesContent":[null],"mappings":";;;;;;AAGA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,CAAA,GAAAF,uBAAA,CAAAC,OAAA;AAGA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAAG,kBAAA,GAAAJ,uBAAA,CAAAC,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,qBAAA,GAAAN,uBAAA,CAAAC,OAAA;AACA,IAAAM,UAAA,GAAAP,uBAAA,CAAAC,OAAA;AAA6C,SAAAO,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAT,wBAAAS,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,C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AAME,eAAe,GAAAV,OAAA,CAAAU,eAAA,gBAsBxBrC,CAAC,CAAC4B,IAAI,CACPC,IAAI,IAAKC,IAAI,CAACD,IAAI,CAAC,CAAC,CAAC,CAAC,EACvB,CAACE,EAAM,EAAEO,MAAiB,EAAEC,OAAgC,KAC1D,IAAInC,qBAAqB,CAACoC,yBAAyB,CAAC;EAAEC,MAAM,EAAEV,EAAE,CAACM,eAAe,CAACC,MAAM,EAAEC,OAAO;AAAC,CAAE,CAAC,CACvG;AAEM,MAAMG,cAAc,GAAAf,OAAA,CAAAe,cAAA,gBAKvB1C,CAAC,CAAC4B,IAAI,CACPC,IAAI,IAAKC,IAAI,CAACD,IAAI,CAAC,CAAC,CAAC,CAAC,EACvB,CAACE,EAAM,EAAEC,IAAY,EAAEO,OAA+B,KACpDvC,CAAC,CAAC2C,IAAI,CACJ9C,MAAM,CAAC+C,OAAO,CAAC,MAAMb,EAAE,CAACW,cAAc,CAACV,IAAI,EAAEO,OAAO,CAAC,CAAC,EACtD1C,MAAM,CAACgD,cAAc,CAAC,IAAAC,2BAAe,EAACC,WAAW,CAAChB,EAAE,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAC1E,CACJ;AAED,MAAMD,IAAI,GAAIkB,CAAU,IAAKA,CAAC,YAAYC,WAAE;AAE5C,MAAMF,WAAW,GAAGA,CAAChB,EAAM,EAAEmB,YAAoB,KAC/C,IAAI7C,UAAU,CAAC8C,aAAa,CAAC;EAAEC,MAAM,EAAE,IAAI;EAAEF,YAAY;EAAEnB,EAAE,EAAEA,EAAE,CAACsB;AAAY,CAAE,CAAC","ignoreList":[]}
@@ -3,11 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.toStream = exports.toArray = exports.DocumentAggregationCursor = void 0;
6
+ exports.toStream = exports.toArray = exports.DocumentAggregationCursorImpl = void 0;
7
7
  var Data = _interopRequireWildcard(require("effect/Data"));
8
8
  var Effect = _interopRequireWildcard(require("effect/Effect"));
9
9
  var F = _interopRequireWildcard(require("effect/Function"));
10
+ var _Pipeable = require("effect/Pipeable");
10
11
  var Stream = _interopRequireWildcard(require("effect/Stream"));
12
+ var _mongoError = require("./internal/mongo-error.js");
11
13
  var MongoError = _interopRequireWildcard(require("./MongoError.js"));
12
14
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
15
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -15,13 +17,21 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
15
17
  * @since 0.0.1
16
18
  */
17
19
 
18
- class DocumentAggregationCursor extends /*#__PURE__*/Data.TaggedClass("DocumentAggregationCursor") {}
19
- exports.DocumentAggregationCursor = DocumentAggregationCursor;
20
- const toArray = cursor => F.pipe(Effect.tryPromise({
21
- try: () => cursor.cursor.toArray(),
22
- catch: F.identity
23
- }), Effect.catchAll(MongoError.mongoErrorDie(`${cursor._tag}.toArray error`)));
20
+ /** @internal */
21
+ class DocumentAggregationCursorImpl extends /*#__PURE__*/Data.TaggedClass("DocumentAggregationCursor") {
22
+ pipe() {
23
+ return (0, _Pipeable.pipeArguments)(this, arguments);
24
+ }
25
+ }
26
+ exports.DocumentAggregationCursorImpl = DocumentAggregationCursorImpl;
27
+ const toArray = cursor => F.pipe(Effect.promise(() => cursor.cursor.toArray()), Effect.catchAllDefect((0, _mongoError.mongoErrorOrDie)(errorSource(cursor, "toArray"))));
24
28
  exports.toArray = toArray;
25
- const toStream = cursor => F.pipe(Stream.fromAsyncIterable(cursor.cursor, F.identity), Stream.catchAll(MongoError.mongoErrorStream(`${cursor._tag}.toStream error`)));
29
+ const toStream = cursor => F.pipe(Stream.fromAsyncIterable(cursor.cursor, F.identity), Stream.catchAll((0, _mongoError.mongoErrorOrDie)(errorSource(cursor, "toStream"))));
26
30
  exports.toStream = toStream;
31
+ const errorSource = (cursor, functionName) => new MongoError.CollectionErrorSource({
32
+ module: DocumentAggregationCursorImpl.name,
33
+ functionName,
34
+ db: cursor.cursor.namespace.db,
35
+ collection: cursor.cursor.namespace.collection ?? "NO_COLLECTION_NAME"
36
+ });
27
37
  //# sourceMappingURL=DocumentAggregationCursor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DocumentAggregationCursor.js","names":["Data","_interopRequireWildcard","require","Effect","F","Stream","MongoError","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","DocumentAggregationCursor","TaggedClass","exports","toArray","cursor","pipe","tryPromise","try","catch","identity","catchAll","mongoErrorDie","_tag","toStream","fromAsyncIterable","mongoErrorStream"],"sources":["../../src/DocumentAggregationCursor.ts"],"sourcesContent":[null],"mappings":";;;;;;AAGA,IAAAA,IAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,uBAAA,CAAAC,OAAA;AACA,IAAAE,CAAA,GAAAH,uBAAA,CAAAC,OAAA;AACA,IAAAG,MAAA,GAAAJ,uBAAA,CAAAC,OAAA;AAEA,IAAAI,UAAA,GAAAL,uBAAA,CAAAC,OAAA;AAA6C,SAAAK,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,C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CAAE,CAAC,EAC5EjC,MAAM,CAACkC,QAAQ,CAAC/B,UAAU,CAACgC,aAAa,CAAkB,GAAGP,MAAM,CAACQ,IAAI,gBAAgB,CAAC,CAAC,CAC3F;AAAAV,OAAA,CAAAC,OAAA,GAAAA,OAAA;AAEI,MAAMU,QAAQ,GACnBT,MAAiC,IAEjC3B,CAAC,CAAC4B,IAAI,CACJ3B,MAAM,CAACoC,iBAAiB,CAACV,MAAM,CAACA,MAAM,EAAE3B,CAAC,CAACgC,QAAQ,CAAC,EACnD/B,MAAM,CAACgC,QAAQ,CAAC/B,UAAU,CAACoC,gBAAgB,CAAW,GAAGX,MAAM,CAACQ,IAAI,iBAAiB,CAAC,CAAC,CACxF;AAAAV,OAAA,CAAAW,QAAA,GAAAA,QAAA","ignoreList":[]}
1
+ {"version":3,"file":"DocumentAggregationCursor.js","names":["Data","_interopRequireWildcard","require","Effect","F","_Pipeable","Stream","_mongoError","MongoError","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","DocumentAggregationCursorImpl","TaggedClass","pipe","pipeArguments","arguments","toArray","cursor","promise","catchAllDefect","mongoErrorOrDie","errorSource","exports","toStream","fromAsyncIterable","identity","catchAll","functionName","CollectionErrorSource","module","name","db","namespace","collection"],"sources":["../../src/DocumentAggregationCursor.ts"],"sourcesContent":[null],"mappings":";;;;;;AAGA,IAAAA,IAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,uBAAA,CAAAC,OAAA;AACA,IAAAE,CAAA,GAAAH,uBAAA,CAAAC,OAAA;AAEA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAL,uBAAA,CAAAC,OAAA;AAEA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAP,uBAAA,CAAAC,OAAA;AAA6C,SAAAO,yBAAAC,CAAA,6BAAAC,OAAA,m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,MAAiC,IAEjC/B,CAAC,CAAC2B,IAAI,CACJ5B,MAAM,CAACiC,OAAO,CAAC,MAAMD,MAAM,CAACA,MAAM,CAACD,OAAO,EAAE,CAAC,EAC7C/B,MAAM,CAACkC,cAAc,CAAC,IAAAC,2BAAe,EAACC,WAAW,CAACJ,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,CACvE;AAAAK,OAAA,CAAAN,OAAA,GAAAA,OAAA;AAEI,MAAMO,QAAQ,GACnBN,MAAiC,IAEjC/B,CAAC,CAAC2B,IAAI,CACJzB,MAAM,CAACoC,iBAAiB,CAACP,MAAM,CAACA,MAAM,EAAE/B,CAAC,CAACuC,QAAQ,CAAC,EACnDrC,MAAM,CAACsC,QAAQ,CAAC,IAAAN,2BAAe,EAACC,WAAW,CAACJ,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,CAClE;AAAAK,OAAA,CAAAC,QAAA,GAAAA,QAAA;AAEH,MAAMF,WAAW,GAAGA,CAACJ,MAAiC,EAAEU,YAAoB,KAC1E,IAAIrC,UAAU,CAACsC,qBAAqB,CAAC;EACnCC,MAAM,EAAElB,6BAA6B,CAACmB,IAAI;EAC1CH,YAAY;EACZI,EAAE,EAAEd,MAAM,CAACA,MAAM,CAACe,SAAS,CAACD,EAAE;EAC9BE,UAAU,EAAEhB,MAAM,CAACA,MAAM,CAACe,SAAS,CAACC,UAAU,IAAI;CACnD,CAAC","ignoreList":[]}
@@ -3,15 +3,17 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.updateMany = exports.typed = exports.replaceOne = exports.rename = exports.insertOne = exports.insertMany = exports.findOneAndReplace = exports.findOne = exports.find = exports.estimatedDocumentCount = exports.dropIndex = exports.drop = exports.deleteOne = exports.deleteMany = exports.createIndexes = exports.createIndex = exports.countDocuments = exports.aggregate = exports.DocumentCollection = void 0;
6
+ exports.updateMany = exports.typed = exports.replaceOne = exports.rename = exports.insertOne = exports.insertMany = exports.findOneAndReplace = exports.findOne = exports.find = exports.estimatedDocumentCount = exports.dropIndex = exports.drop = exports.deleteOne = exports.deleteMany = exports.createIndexes = exports.createIndex = exports.countDocuments = exports.aggregate = exports.DocumentCollectionImpl = void 0;
7
7
  var Array = _interopRequireWildcard(require("effect/Array"));
8
8
  var Data = _interopRequireWildcard(require("effect/Data"));
9
9
  var Effect = _interopRequireWildcard(require("effect/Effect"));
10
10
  var F = _interopRequireWildcard(require("effect/Function"));
11
11
  var O = _interopRequireWildcard(require("effect/Option"));
12
+ var _Pipeable = require("effect/Pipeable");
12
13
  var Collection = _interopRequireWildcard(require("./Collection.js"));
13
14
  var DocumentAggregationCursor = _interopRequireWildcard(require("./DocumentAggregationCursor.js"));
14
15
  var DocumentFindCursor = _interopRequireWildcard(require("./DocumentFindCursor.js"));
16
+ var _mongoError = require("./internal/mongo-error.js");
15
17
  var MongoError = _interopRequireWildcard(require("./MongoError.js"));
16
18
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
17
19
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -19,18 +21,23 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
19
21
  * @since 0.0.1
20
22
  */
21
23
 
22
- class DocumentCollection extends /*#__PURE__*/Data.TaggedClass("DocumentCollection") {}
23
- exports.DocumentCollection = DocumentCollection;
24
- const find = exports.find = /*#__PURE__*/F.dual(args => isDocumentCollection(args[0]), (collection, filter, options) => new DocumentFindCursor.DocumentFindCursor({
24
+ /** @internal */
25
+ class DocumentCollectionImpl extends /*#__PURE__*/Data.TaggedClass("DocumentCollection") {
26
+ pipe() {
27
+ return (0, _Pipeable.pipeArguments)(this, arguments);
28
+ }
29
+ }
30
+ exports.DocumentCollectionImpl = DocumentCollectionImpl;
31
+ const find = exports.find = /*#__PURE__*/F.dual(args => isDocumentCollection(args[0]), (collection, filter, options) => new DocumentFindCursor.DocumentFindCursorImpl({
25
32
  cursor: collection.collection.find(filter ?? {}, options)
26
33
  }));
27
- const findOne = exports.findOne = /*#__PURE__*/F.dual(args => isDocumentCollection(args[0]), (collection, filter, options) => F.pipe(Effect.promise(() => collection.collection.findOne(filter, options)), Effect.map(value => O.fromNullable(value)), Effect.catchAllDefect(MongoError.mongoErrorDie("findOne error"))));
28
- const insertOne = exports.insertOne = /*#__PURE__*/F.dual(args => isDocumentCollection(args[0]), (collection, doc, options) => F.pipe(Effect.promise(() => collection.collection.insertOne(doc, options)), Effect.catchAllDefect(MongoError.mongoErrorDie("insertOne error"))));
29
- const insertMany = exports.insertMany = /*#__PURE__*/F.dual(args => isDocumentCollection(args[0]), (collection, docs, options) => F.pipe(Effect.promise(() => collection.collection.insertMany(docs, options)), Effect.catchAllDefect(MongoError.mongoErrorDie("insertMany error"))));
30
- const deleteOne = exports.deleteOne = /*#__PURE__*/F.dual(args => isDocumentCollection(args[0]), (collection, filter, options) => F.pipe(Effect.promise(() => collection.collection.deleteOne(filter, options)), Effect.catchAllDefect(MongoError.mongoErrorDie("deleteOne error"))));
31
- const deleteMany = exports.deleteMany = /*#__PURE__*/F.dual(args => isDocumentCollection(args[0]), (collection, filter, options) => F.pipe(Effect.promise(() => collection.collection.deleteMany(filter, options)), Effect.catchAllDefect(MongoError.mongoErrorDie("deleteMany error"))));
32
- const updateMany = exports.updateMany = /*#__PURE__*/F.dual(args => isDocumentCollection(args[0]), (collection, filter, update, options) => F.pipe(Effect.promise(() => collection.collection.updateMany(filter, Array.isArray(update) ? [...update] : update, options)), Effect.catchAllDefect(MongoError.mongoErrorDie("updateMany error"))));
33
- const replaceOne = exports.replaceOne = /*#__PURE__*/F.dual(args => isDocumentCollection(args[0]), (collection, filter, replacement, options) => F.pipe(Effect.promise(() => collection.collection.replaceOne(filter, replacement, options)), Effect.catchAllDefect(MongoError.mongoErrorDie("replaceOne error"))));
34
+ const findOne = exports.findOne = /*#__PURE__*/F.dual(args => isDocumentCollection(args[0]), (collection, filter, options) => F.pipe(Effect.promise(() => collection.collection.findOne(filter, options)), Effect.map(value => O.fromNullable(value)), Effect.catchAllDefect((0, _mongoError.mongoErrorOrDie)(errorSource(collection, "findOne")))));
35
+ const insertOne = exports.insertOne = /*#__PURE__*/F.dual(args => isDocumentCollection(args[0]), (collection, doc, options) => F.pipe(Effect.promise(() => collection.collection.insertOne(doc, options)), Effect.catchAllDefect((0, _mongoError.mongoErrorOrDie)(errorSource(collection, "insertOne")))));
36
+ const insertMany = exports.insertMany = /*#__PURE__*/F.dual(args => isDocumentCollection(args[0]), (collection, docs, options) => F.pipe(Effect.promise(() => collection.collection.insertMany(docs, options)), Effect.catchAllDefect((0, _mongoError.mongoErrorOrDie)(errorSource(collection, "insertMany")))));
37
+ const deleteOne = exports.deleteOne = /*#__PURE__*/F.dual(args => isDocumentCollection(args[0]), (collection, filter, options) => F.pipe(Effect.promise(() => collection.collection.deleteOne(filter, options)), Effect.catchAllDefect((0, _mongoError.mongoErrorOrDie)(errorSource(collection, "deleteOne")))));
38
+ const deleteMany = exports.deleteMany = /*#__PURE__*/F.dual(args => isDocumentCollection(args[0]), (collection, filter, options) => F.pipe(Effect.promise(() => collection.collection.deleteMany(filter, options)), Effect.catchAllDefect((0, _mongoError.mongoErrorOrDie)(errorSource(collection, "deleteMany")))));
39
+ const updateMany = exports.updateMany = /*#__PURE__*/F.dual(args => isDocumentCollection(args[0]), (collection, filter, update, options) => F.pipe(Effect.promise(() => collection.collection.updateMany(filter, Array.isArray(update) ? [...update] : update, options)), Effect.catchAllDefect((0, _mongoError.mongoErrorOrDie)(errorSource(collection, "updateMany")))));
40
+ const replaceOne = exports.replaceOne = /*#__PURE__*/F.dual(args => isDocumentCollection(args[0]), (collection, filter, replacement, options) => F.pipe(Effect.promise(() => collection.collection.replaceOne(filter, replacement, options)), Effect.catchAllDefect((0, _mongoError.mongoErrorOrDie)(errorSource(collection, "replaceOne")))));
34
41
  const findOneAndReplace = exports.findOneAndReplace = /*#__PURE__*/F.dual(args => isDocumentCollection(args[0]), (collection, filter, replacement, options) => F.pipe(Effect.promise(() => collection.collection.findOneAndReplace(filter, replacement, options ?? {})), Effect.map(value => {
35
42
  if (options?.includeResultMetadata && !!value) {
36
43
  const result = value;
@@ -40,23 +47,28 @@ const findOneAndReplace = exports.findOneAndReplace = /*#__PURE__*/F.dual(args =
40
47
  };
41
48
  }
42
49
  return O.fromNullable(value);
43
- }), Effect.catchAllDefect(MongoError.mongoErrorDie("findOneAndReplace error"))));
44
- const rename = exports.rename = /*#__PURE__*/F.dual(args => isDocumentCollection(args[0]), (collection, newName, options) => F.pipe(Effect.promise(() => collection.collection.rename(newName, options)), Effect.map(collection => new DocumentCollection({
50
+ }), Effect.catchAllDefect((0, _mongoError.mongoErrorOrDie)(errorSource(collection, "findOneAndReplace")))));
51
+ const rename = exports.rename = /*#__PURE__*/F.dual(args => isDocumentCollection(args[0]), (collection, newName, options) => F.pipe(Effect.promise(() => collection.collection.rename(newName, options)), Effect.map(collection => new DocumentCollectionImpl({
45
52
  collection
46
- })), Effect.catchAllDefect(MongoError.mongoErrorDie("rename error"))));
47
- const drop = exports.drop = /*#__PURE__*/F.dual(args => isDocumentCollection(args[0]), (collection, options) => F.pipe(Effect.promise(() => collection.collection.drop(options)), Effect.catchAllDefect(MongoError.mongoErrorDie("drop error"))));
48
- const createIndexes = exports.createIndexes = /*#__PURE__*/F.dual(args => isDocumentCollection(args[0]), (collection, indexSpecs, options) => F.pipe(Effect.promise(() => collection.collection.createIndexes([...indexSpecs], options)), Effect.catchAllDefect(MongoError.mongoErrorDie("createIndexes error"))));
49
- const createIndex = exports.createIndex = /*#__PURE__*/F.dual(args => isDocumentCollection(args[0]), (collection, indexSpec, options) => F.pipe(Effect.promise(() => collection.collection.createIndex(indexSpec, options)), Effect.catchAllDefect(MongoError.mongoErrorDie("createIndex error"))));
50
- // TODO: review return type. Should we return Document like mongodb driver?
51
- const dropIndex = exports.dropIndex = /*#__PURE__*/F.dual(args => isDocumentCollection(args[0]), (collection, indexName, options) => F.pipe(Effect.promise(() => collection.collection.dropIndex(indexName, options)), Effect.asVoid, Effect.catchAllDefect(MongoError.mongoErrorDie("dropIndex error"))));
52
- const aggregate = exports.aggregate = /*#__PURE__*/F.dual(args => isDocumentCollection(args[0]), (collection, pipeline, options) => new DocumentAggregationCursor.DocumentAggregationCursor({
53
+ })), Effect.catchAllDefect((0, _mongoError.mongoErrorOrDie)(errorSource(collection, "rename")))));
54
+ const drop = exports.drop = /*#__PURE__*/F.dual(args => isDocumentCollection(args[0]), (collection, options) => F.pipe(Effect.promise(() => collection.collection.drop(options)), Effect.catchAllDefect((0, _mongoError.mongoErrorOrDie)(errorSource(collection, "drop")))));
55
+ const createIndexes = exports.createIndexes = /*#__PURE__*/F.dual(args => isDocumentCollection(args[0]), (collection, indexSpecs, options) => F.pipe(Effect.promise(() => collection.collection.createIndexes([...indexSpecs], options)), Effect.catchAllDefect((0, _mongoError.mongoErrorOrDie)(errorSource(collection, "createIndexes")))));
56
+ const createIndex = exports.createIndex = /*#__PURE__*/F.dual(args => isDocumentCollection(args[0]), (collection, indexSpec, options) => F.pipe(Effect.promise(() => collection.collection.createIndex(indexSpec, options)), Effect.catchAllDefect((0, _mongoError.mongoErrorOrDie)(errorSource(collection, "createIndex")))));
57
+ const dropIndex = exports.dropIndex = /*#__PURE__*/F.dual(args => isDocumentCollection(args[0]), (collection, indexName, options) => F.pipe(Effect.promise(() => collection.collection.dropIndex(indexName, options)), Effect.catchAllDefect((0, _mongoError.mongoErrorOrDie)(errorSource(collection, "dropIndex")))));
58
+ const aggregate = exports.aggregate = /*#__PURE__*/F.dual(args => isDocumentCollection(args[0]), (collection, pipeline, options) => new DocumentAggregationCursor.DocumentAggregationCursorImpl({
53
59
  cursor: collection.collection.aggregate(pipeline ? [...pipeline] : undefined, options)
54
60
  }));
55
- const estimatedDocumentCount = exports.estimatedDocumentCount = /*#__PURE__*/F.dual(args => isDocumentCollection(args[0]), (collection, options) => F.pipe(Effect.promise(() => collection.collection.estimatedDocumentCount(options)), Effect.catchAllDefect(MongoError.mongoErrorDie("estimatedDocumentCount error"))));
56
- const countDocuments = exports.countDocuments = /*#__PURE__*/F.dual(args => isDocumentCollection(args[0]), (collection, filter, options) => F.pipe(Effect.promise(() => collection.collection.countDocuments(filter, options)), Effect.catchAllDefect(MongoError.mongoErrorDie("countDocuments error"))));
57
- const typed = exports.typed = /*#__PURE__*/F.dual(args => isDocumentCollection(args[0]), (collection, schema) => new Collection.Collection({
61
+ const estimatedDocumentCount = exports.estimatedDocumentCount = /*#__PURE__*/F.dual(args => isDocumentCollection(args[0]), (collection, options) => F.pipe(Effect.promise(() => collection.collection.estimatedDocumentCount(options)), Effect.catchAllDefect((0, _mongoError.mongoErrorOrDie)(errorSource(collection, "estimatedDocumentCount")))));
62
+ const countDocuments = exports.countDocuments = /*#__PURE__*/F.dual(args => isDocumentCollection(args[0]), (collection, filter, options) => F.pipe(Effect.promise(() => collection.collection.countDocuments(filter, options)), Effect.catchAllDefect((0, _mongoError.mongoErrorOrDie)(errorSource(collection, "countDocuments")))));
63
+ const typed = exports.typed = /*#__PURE__*/F.dual(args => isDocumentCollection(args[0]), (collection, schema) => new Collection.CollectionImpl({
58
64
  collection: collection.collection,
59
65
  schema
60
66
  }));
61
- const isDocumentCollection = x => x instanceof DocumentCollection;
67
+ const isDocumentCollection = x => x instanceof DocumentCollectionImpl;
68
+ const errorSource = (collection, functionName) => new MongoError.CollectionErrorSource({
69
+ module: DocumentCollectionImpl.name,
70
+ functionName,
71
+ db: collection.collection.dbName,
72
+ collection: collection.collection.collectionName
73
+ });
62
74
  //# sourceMappingURL=DocumentCollection.js.map