This commit is contained in:
Jonasz Bigda
2023-03-25 21:51:42 +01:00
parent 0db1d5117e
commit b332e9ceb0
1044 changed files with 37502 additions and 63938 deletions

View File

@@ -4,13 +4,27 @@ const get = require('../get');
module.exports = function applyWriteConcern(schema, options) {
const writeConcern = get(schema, 'options.writeConcern', {});
if (!('w' in options) && writeConcern.w != null) {
options.w = writeConcern.w;
if (Object.keys(writeConcern).length != 0) {
options.writeConcern = {};
if (!('w' in options) && writeConcern.w != null) {
options.writeConcern.w = writeConcern.w;
}
if (!('j' in options) && writeConcern.j != null) {
options.writeConcern.j = writeConcern.j;
}
if (!('wtimeout' in options) && writeConcern.wtimeout != null) {
options.writeConcern.wtimeout = writeConcern.wtimeout;
}
}
if (!('j' in options) && writeConcern.j != null) {
options.j = writeConcern.j;
}
if (!('wtimeout' in options) && writeConcern.wtimeout != null) {
options.wtimeout = writeConcern.wtimeout;
else {
if (!('w' in options) && writeConcern.w != null) {
options.w = writeConcern.w;
}
if (!('j' in options) && writeConcern.j != null) {
options.j = writeConcern.j;
}
if (!('wtimeout' in options) && writeConcern.wtimeout != null) {
options.wtimeout = writeConcern.wtimeout;
}
}
};

View File

@@ -7,6 +7,6 @@
module.exports = function cleanPositionalOperators(path) {
return path.
replace(/\.\$(\[[^\]]*\])?\./g, '.0.').
replace(/\.(\[[^\]]*\])?\$$/g, '.0');
replace(/\.\$(\[[^\]]*\])?(?=\.)/g, '.0').
replace(/\.\$(\[[^\]]*\])?$/g, '.0');
};

View File

@@ -1,7 +1,15 @@
'use strict';
module.exports = function merge(s1, s2) {
s1.add(s2.tree || {});
module.exports = function merge(s1, s2, skipConflictingPaths) {
const paths = Object.keys(s2.tree);
const pathsToAdd = {};
for (const key of paths) {
if (skipConflictingPaths && (s1.paths[key] || s1.nested[key] || s1.singleNestedPaths[key])) {
continue;
}
pathsToAdd[key] = s2.tree[key];
}
s1.add(pathsToAdd);
s1.callQueue = s1.callQueue.concat(s2.callQueue);
s1.method(s2.methods);