Replace underscore usage in mongo package

This commit is contained in:
harryadel
2024-10-17 19:13:28 +03:00
parent e9b5df5754
commit 83a14a2078
5 changed files with 10 additions and 11 deletions

View File

@@ -1099,7 +1099,7 @@ class AsynchronousCursor {
if (!doc) return null;
doc = replaceTypes(doc, replaceMongoAtomWithMeteor);
if (!this._cursorDescription.options.tailable && _.has(doc, '_id')) {
if (!this._cursorDescription.options.tailable && doc._id) {
// Did Mongo give us duplicate documents in the same cursor? If so,
// ignore this one. (Do this before the transform, since transform might
// return some unrelated value.) We don't do this for tailable cursors,
@@ -1174,7 +1174,8 @@ class AsynchronousCursor {
}
fetch() {
return this.map(_.identity);
var self = this;
return self.map(x => x);
}
/**
@@ -1634,9 +1635,9 @@ forEachTrigger = async function (cursorDescription, triggerCallback) {
cursorDescription.selector);
if (specificIds) {
for (const id of specificIds) {
await triggerCallback(_.extend({id: id}, key));
await triggerCallback(Object.assign({id: id}, key));
}
await triggerCallback(_.extend({dropCollection: true, id: null}, key));
await triggerCallback(Object.assign({dropCollection: true, id: null}, key));
} else {
await triggerCallback(key);
}

View File

@@ -26,7 +26,7 @@ ObserveMultiplexer = class {
const self = this;
this.callbackNames().forEach(callbackName => {
this[callbackName] = function(/* ... */) {
self._applyCallback(callbackName, _.toArray(arguments));
self._applyCallback(callbackName, [...arguments]);
};
});
}

View File

@@ -118,7 +118,7 @@ OplogObserveDriver = function (options) {
};
_.extend(OplogObserveDriver.prototype, {
Object.assign(OplogObserveDriver.prototype, {
_init: async function() {
const self = this;

View File

@@ -43,7 +43,7 @@ PollingObserveDriver = function (options) {
};
_.extend(PollingObserveDriver.prototype, {
Object.assign(PollingObserveDriver.prototype, {
_init: async function () {
const self = this;
const options = self._options;

View File

@@ -47,11 +47,9 @@ Object.assign(MongoInternals.RemoteCollectionDriver.prototype, {
});
CLIENT_ONLY_METHODS.forEach(function (m) {
ret[m] = _.bind(self.mongo[m], self.mongo, name);
ret[m] = function (...args) {
throw new Error(
`${m} + is not available on the server. Please use ${getAsyncMethodName(
`${m} is not available on the server. Please use ${getAsyncMethodName(
m
)}() instead.`
);
@@ -88,4 +86,4 @@ MongoInternals.defaultRemoteCollectionDriver = once(function () {
});
return driver;
});
});