@livequery/mongoose 2.0.50 → 2.0.51

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.
@@ -1,6 +1,5 @@
1
1
  import { Cursor } from './Cursor.js';
2
2
  import { MongoQuery } from "./MongoQuery.js";
3
- import mongoose from 'mongoose';
4
3
  import { ObjectId } from 'bson';
5
4
  import { SmartCache } from './SmartCache.js';
6
5
  import { Subject } from 'rxjs/internal/Subject';
@@ -142,10 +141,10 @@ export class MongooseDatasource extends Subject {
142
141
  return {
143
142
  ...obj,
144
143
  ...[...fields].reduce((p, c) => {
145
- if (obj[c] && typeof obj[c] == 'string' && mongoose.Types.ObjectId.isValid(obj[c])) {
144
+ if (obj[c] && typeof obj[c] == 'string' && ObjectId.isValid(obj[c])) {
146
145
  return {
147
146
  ...p,
148
- [c]: new mongoose.Types.ObjectId(obj[c])
147
+ [c]: ObjectId.createFromHexString(obj[c])
149
148
  };
150
149
  }
151
150
  return p;
@@ -155,8 +154,8 @@ export class MongooseDatasource extends Subject {
155
154
  async normalizeRef(req, schema) {
156
155
  const fields = await this.#schemas.get(schema, async () => {
157
156
  return new Set(Object.entries(schema.paths).filter(([k, v]) => {
158
- return (v.instance == 'Array' ? v.getEmbeddedSchemaType().instance : v.instance) == 'ObjectID';
159
- }).map(([k, v]) => k));
157
+ return (v.instance == 'Array' ? v.getEmbeddedSchemaType().instance : v.instance) == 'ObjectId';
158
+ }).map(([k]) => k));
160
159
  });
161
160
  if (fields.size == 0)
162
161
  return req;
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "repository": {
7
7
  "url": "git@github.com:livequery/mongoose.git"
8
8
  },
9
- "version": "2.0.50",
9
+ "version": "2.0.51",
10
10
  "description": "Mongoose datasource mapping for @livequery ecosystem",
11
11
  "main": "./build/src/index.js",
12
12
  "types": "./build/src/index.d.ts",