add a configuration option for default promise resolver

This commit is contained in:
Nacho Codoñer
2024-02-12 19:25:08 +01:00
parent 282035ef68
commit 14942c4e70
2 changed files with 4 additions and 3 deletions

View File

@@ -619,9 +619,9 @@ CollectionPrototype._callMutatorMethodAsync = function _callMutatorMethodAsync(n
const mutatorMethodName = this._prefix + name;
return this._connection.applyAsync(mutatorMethodName, args, {
returnStubValue: true,
returnStubValue: Meteor.isClient && (this.promiseResolver === 'stub' || this.promiseResolver == null),
// StubStream is only used for testing where you don't care about the server
returnServerResultPromise: !this._connection._stream._isStub,
returnServerResultPromise: !this._connection._stream._isStub || Meteor.isClient && this.promiseResolver === 'server',
...options,
});
}

View File

@@ -89,6 +89,8 @@ Mongo.Collection = function Collection(name, options) {
this._transform = LocalCollection.wrapTransform(options.transform);
this.promiseResolver = options.promiseResolver;
if (!name || options.connection === null)
// note: nameless collections never have a connection
this._connection = null;
@@ -1266,4 +1268,3 @@ function popCallbackFromArgs(args) {
return args.pop();
}
}