mongoose 6.13.9 → 6.13.10
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/browser.umd.js +1 -1
- package/lib/document.js +10 -3
- package/lib/schema.js +10 -6
- package/package.json +1 -1
- package/.claude/settings.local.json +0 -7
- package/startmdb.mjs +0 -19
package/lib/document.js
CHANGED
|
@@ -58,6 +58,7 @@ let MongooseArray;
|
|
|
58
58
|
let Embedded;
|
|
59
59
|
|
|
60
60
|
const specialProperties = utils.specialProperties;
|
|
61
|
+
const hasOwnProperty = utils.object.hasOwnProperty;
|
|
61
62
|
|
|
62
63
|
/**
|
|
63
64
|
* The core Mongoose document constructor. You should not call this directly,
|
|
@@ -1869,7 +1870,9 @@ Document.prototype.get = function(path, type, options) {
|
|
|
1869
1870
|
|
|
1870
1871
|
// Fast path if we know we're just accessing top-level path on the document:
|
|
1871
1872
|
// just get the schema path, avoid `$__path()` because that does string manipulation
|
|
1872
|
-
let schema = noDottedPath ?
|
|
1873
|
+
let schema = noDottedPath ?
|
|
1874
|
+
hasOwnProperty(this.$__schema.paths, path) ? this.$__schema.paths[path] : undefined :
|
|
1875
|
+
this.$__path(path);
|
|
1873
1876
|
if (schema == null) {
|
|
1874
1877
|
schema = this.$__schema.virtualpath(path);
|
|
1875
1878
|
|
|
@@ -1879,7 +1882,7 @@ Document.prototype.get = function(path, type, options) {
|
|
|
1879
1882
|
}
|
|
1880
1883
|
|
|
1881
1884
|
if (noDottedPath) {
|
|
1882
|
-
let obj = this._doc[path];
|
|
1885
|
+
let obj = hasOwnProperty(this._doc, path) ? this._doc[path] : undefined;
|
|
1883
1886
|
if (adhoc) {
|
|
1884
1887
|
obj = adhoc.cast(obj);
|
|
1885
1888
|
}
|
|
@@ -1906,6 +1909,10 @@ Document.prototype.get = function(path, type, options) {
|
|
|
1906
1909
|
}
|
|
1907
1910
|
|
|
1908
1911
|
for (let i = 0, l = pieces.length; i < l; i++) {
|
|
1912
|
+
if (specialProperties.has(pieces[i])) {
|
|
1913
|
+
return undefined;
|
|
1914
|
+
}
|
|
1915
|
+
|
|
1909
1916
|
if (obj && obj._doc) {
|
|
1910
1917
|
obj = obj._doc;
|
|
1911
1918
|
}
|
|
@@ -1927,7 +1934,7 @@ Document.prototype.get = function(path, type, options) {
|
|
|
1927
1934
|
|
|
1928
1935
|
if (schema != null && options.getters !== false) {
|
|
1929
1936
|
obj = schema.applyGetters(obj, this);
|
|
1930
|
-
} else if (this.$__schema.nested
|
|
1937
|
+
} else if (hasOwnProperty(this.$__schema.nested, path) && options.virtuals) {
|
|
1931
1938
|
// Might need to apply virtuals if this is a nested path
|
|
1932
1939
|
return applyVirtuals(this, utils.clone(obj) || {}, { path: path });
|
|
1933
1940
|
}
|
package/lib/schema.js
CHANGED
|
@@ -955,7 +955,7 @@ reserved.collection = 1;
|
|
|
955
955
|
|
|
956
956
|
Schema.prototype.path = function(path, obj) {
|
|
957
957
|
if (obj === undefined) {
|
|
958
|
-
if (this.paths
|
|
958
|
+
if (Object.prototype.hasOwnProperty.call(this.paths, path)) {
|
|
959
959
|
return this.paths[path];
|
|
960
960
|
}
|
|
961
961
|
// Convert to '.$' to check subpaths re: gh-6405
|
|
@@ -983,9 +983,15 @@ Schema.prototype.path = function(path, obj) {
|
|
|
983
983
|
: undefined;
|
|
984
984
|
}
|
|
985
985
|
|
|
986
|
+
const subpaths = path.indexOf('.') === -1 ? [path] : path.split('.');
|
|
987
|
+
const last = subpaths.pop();
|
|
988
|
+
if (utils.specialProperties.has(last)) {
|
|
989
|
+
throw new Error('Cannot set special property `' + last + '` on a schema');
|
|
990
|
+
}
|
|
991
|
+
|
|
986
992
|
// some path names conflict with document methods
|
|
987
|
-
const firstPieceOfPath =
|
|
988
|
-
if (reserved
|
|
993
|
+
const firstPieceOfPath = subpaths.length === 0 ? last : subpaths[0];
|
|
994
|
+
if (Object.prototype.hasOwnProperty.call(reserved, firstPieceOfPath) && !this.options.supressReservedKeysWarning) {
|
|
989
995
|
const errorMessage = `\`${firstPieceOfPath}\` is a reserved schema pathname and may break some functionality. ` +
|
|
990
996
|
'You are allowed to use it, but use at your own risk. ' +
|
|
991
997
|
'To disable this warning pass `supressReservedKeysWarning` as a schema option.';
|
|
@@ -998,8 +1004,6 @@ Schema.prototype.path = function(path, obj) {
|
|
|
998
1004
|
}
|
|
999
1005
|
|
|
1000
1006
|
// update the tree
|
|
1001
|
-
const subpaths = path.split(/\./);
|
|
1002
|
-
const last = subpaths.pop();
|
|
1003
1007
|
let branch = this.tree;
|
|
1004
1008
|
let fullPath = '';
|
|
1005
1009
|
|
|
@@ -2589,7 +2593,7 @@ Schema.prototype._getPathType = function(path) {
|
|
|
2589
2593
|
};
|
|
2590
2594
|
}
|
|
2591
2595
|
return { schema: foundschema, pathType: 'real' };
|
|
2592
|
-
} else if (p === parts.length && schema.nested
|
|
2596
|
+
} else if (p === parts.length && Object.prototype.hasOwnProperty.call(schema.nested, trypath)) {
|
|
2593
2597
|
return { schema: schema, pathType: 'nested' };
|
|
2594
2598
|
}
|
|
2595
2599
|
}
|
package/package.json
CHANGED
package/startmdb.mjs
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { MongoMemoryReplSet } from 'mongodb-memory-server';
|
|
2
|
-
|
|
3
|
-
const replSet = await MongoMemoryReplSet.create({
|
|
4
|
-
binary: {
|
|
5
|
-
systemBinary: '/home/v/libs/mongodb-linux-x86_64-enterprise-ubuntu2404-8.2.0/bin/mongod'
|
|
6
|
-
},
|
|
7
|
-
instanceOpts: [
|
|
8
|
-
{
|
|
9
|
-
port: 27017
|
|
10
|
-
}
|
|
11
|
-
],
|
|
12
|
-
replSet: {
|
|
13
|
-
storageEngine: 'inMemory',
|
|
14
|
-
count: 1
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
const uri = replSet.getUri();
|
|
19
|
-
console.log(uri);
|