@orion-js/mongodb 4.2.10 → 4.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -315,7 +315,7 @@ function typedId(prefix) {
315
315
  // src/service/index.ts
316
316
  var import_services = require("@orion-js/services");
317
317
 
318
- // ../../node_modules/.pnpm/rambdax@11.3.1/node_modules/rambdax/src/type.js
318
+ // ../../node_modules/.bun/rambdax@11.3.1/node_modules/rambdax/src/type.js
319
319
  function type(input) {
320
320
  if (input === null) {
321
321
  return "Null";
@@ -328,21 +328,21 @@ function type(input) {
328
328
  return typeResult === "AsyncFunction" ? "Promise" : typeResult;
329
329
  }
330
330
 
331
- // ../../node_modules/.pnpm/rambdax@11.3.1/node_modules/rambdax/src/_internals/isArray.js
331
+ // ../../node_modules/.bun/rambdax@11.3.1/node_modules/rambdax/src/_internals/isArray.js
332
332
  var { isArray } = Array;
333
333
 
334
- // ../../node_modules/.pnpm/rambdax@11.3.1/node_modules/rambdax/src/_internals/isInteger.js
334
+ // ../../node_modules/.bun/rambdax@11.3.1/node_modules/rambdax/src/_internals/isInteger.js
335
335
  function _isInteger(n) {
336
336
  return n << 0 === n;
337
337
  }
338
338
  var isInteger = Number.isInteger || _isInteger;
339
339
 
340
- // ../../node_modules/.pnpm/rambdax@11.3.1/node_modules/rambdax/src/_internals/createPath.js
340
+ // ../../node_modules/.bun/rambdax@11.3.1/node_modules/rambdax/src/_internals/createPath.js
341
341
  function createPath(path, delimiter = ".") {
342
342
  return typeof path === "string" ? path.split(delimiter).map((x) => isInteger(x) ? Number(x) : x) : path;
343
343
  }
344
344
 
345
- // ../../node_modules/.pnpm/rambdax@11.3.1/node_modules/rambdax/src/equals.js
345
+ // ../../node_modules/.bun/rambdax@11.3.1/node_modules/rambdax/src/equals.js
346
346
  function _indexOf(valueToFind, list) {
347
347
  if (!isArray(list))
348
348
  throw new Error(`Cannot read property 'indexOf' of ${list}`);
@@ -447,7 +447,7 @@ function equals(a, b) {
447
447
  return false;
448
448
  }
449
449
 
450
- // ../../node_modules/.pnpm/rambdax@11.3.1/node_modules/rambdax/src/isType.js
450
+ // ../../node_modules/.bun/rambdax@11.3.1/node_modules/rambdax/src/isType.js
451
451
  function isType(xType, x) {
452
452
  if (arguments.length === 1) {
453
453
  return (xHolder) => isType(xType, xHolder);
@@ -455,12 +455,12 @@ function isType(xType, x) {
455
455
  return type(x) === xType;
456
456
  }
457
457
 
458
- // ../../node_modules/.pnpm/rambdax@11.3.1/node_modules/rambdax/src/_internals/compare.js
458
+ // ../../node_modules/.bun/rambdax@11.3.1/node_modules/rambdax/src/_internals/compare.js
459
459
  function compare(a, b) {
460
460
  return String(a) === String(b);
461
461
  }
462
462
 
463
- // ../../node_modules/.pnpm/rambdax@11.3.1/node_modules/rambdax/src/_internals/includes.js
463
+ // ../../node_modules/.bun/rambdax@11.3.1/node_modules/rambdax/src/_internals/includes.js
464
464
  function includes(a, list) {
465
465
  let index = -1;
466
466
  const { length } = list;
@@ -470,7 +470,7 @@ function includes(a, list) {
470
470
  return false;
471
471
  }
472
472
 
473
- // ../../node_modules/.pnpm/rambdax@11.3.1/node_modules/rambdax/src/omit.js
473
+ // ../../node_modules/.bun/rambdax@11.3.1/node_modules/rambdax/src/omit.js
474
474
  function omit(propsToOmit, obj) {
475
475
  if (arguments.length === 1) return (_obj) => omit(propsToOmit, _obj);
476
476
  if (obj === null || obj === void 0)
@@ -483,7 +483,7 @@ function omit(propsToOmit, obj) {
483
483
  return willReturn;
484
484
  }
485
485
 
486
- // ../../node_modules/.pnpm/rambdax@11.3.1/node_modules/rambdax/src/isEmpty.js
486
+ // ../../node_modules/.bun/rambdax@11.3.1/node_modules/rambdax/src/isEmpty.js
487
487
  function isEmpty(input) {
488
488
  const inputType = type(input);
489
489
  if (["Undefined", "NaN", "Number", "Null"].includes(inputType))
@@ -498,7 +498,7 @@ function isEmpty(input) {
498
498
  return false;
499
499
  }
500
500
 
501
- // ../../node_modules/.pnpm/rambdax@11.3.1/node_modules/rambdax/src/isNil.js
501
+ // ../../node_modules/.bun/rambdax@11.3.1/node_modules/rambdax/src/isNil.js
502
502
  function isNil(x) {
503
503
  return x === void 0 || x === null;
504
504
  }
@@ -1424,7 +1424,7 @@ async function loadIndexes(collection) {
1424
1424
 
1425
1425
  // src/createCollection/getSchemaAndModel.ts
1426
1426
  var import_helpers7 = require("@orion-js/helpers");
1427
- Symbol.metadata ?? (Symbol.metadata = Symbol("Symbol.metadata"));
1427
+ Symbol.metadata ?? (Symbol.metadata = /* @__PURE__ */ Symbol("Symbol.metadata"));
1428
1428
  function prepareShema(schema) {
1429
1429
  if (!schema._id) {
1430
1430
  schema._id = {
@@ -1606,26 +1606,37 @@ function createCollection(options) {
1606
1606
 
1607
1607
  // src/service/index.ts
1608
1608
  var serviceMetadata = /* @__PURE__ */ new WeakMap();
1609
+ var pendingCollectionOptions = {};
1610
+ var hasMongoCollectionFields = false;
1609
1611
  function Repository() {
1610
1612
  return (target, context) => {
1613
+ const options = pendingCollectionOptions;
1614
+ pendingCollectionOptions = {};
1615
+ hasMongoCollectionFields = false;
1611
1616
  (0, import_services.Service)()(target, context);
1612
- context.addInitializer(function() {
1613
- serviceMetadata.set(this, { _serviceType: "repo" });
1614
- });
1617
+ serviceMetadata.set(target, { _serviceType: "repo" });
1618
+ if (Object.keys(options).length > 0) {
1619
+ const factories = {};
1620
+ for (const [key, opts] of Object.entries(options)) {
1621
+ factories[key] = () => createCollection(opts);
1622
+ }
1623
+ (0, import_services.registerFieldFactories)(target, factories);
1624
+ }
1615
1625
  };
1616
1626
  }
1617
1627
  function MongoCollection(options) {
1618
1628
  return (_target, context) => {
1619
1629
  const propertyKey = String(context.name);
1620
- context.addInitializer(function() {
1621
- const repo = serviceMetadata.get(this.constructor);
1622
- if (!repo || repo._serviceType !== "repo") {
1630
+ pendingCollectionOptions[propertyKey] = options;
1631
+ hasMongoCollectionFields = true;
1632
+ (0, import_services.addPendingFieldValidator)(() => {
1633
+ if (hasMongoCollectionFields) {
1634
+ hasMongoCollectionFields = false;
1635
+ pendingCollectionOptions = {};
1623
1636
  throw new Error(
1624
1637
  "You must pass a class decorated with @Repository if you want to use @MongoCollection"
1625
1638
  );
1626
1639
  }
1627
- const collection = createCollection(options);
1628
- this[propertyKey] = collection;
1629
1640
  });
1630
1641
  };
1631
1642
  }