diff --git a/packages/ddp-client/common/livedata_connection.js b/packages/ddp-client/common/livedata_connection.js index fef6357d67..faa624f76e 100644 --- a/packages/ddp-client/common/livedata_connection.js +++ b/packages/ddp-client/common/livedata_connection.js @@ -864,7 +864,7 @@ export class Connection { // block waiting for the result. if (future) { return options.returnStubValue - ? future + ? stubReturnValue : { stubValuePromise: future, }; diff --git a/packages/mongo/collection.js b/packages/mongo/collection.js index f1d94a0859..8e35cbfeb6 100644 --- a/packages/mongo/collection.js +++ b/packages/mongo/collection.js @@ -783,11 +783,6 @@ Object.assign(Mongo.Collection.prototype, { return result; }; - // const wrappedCallback = wrapCallback( - // callback, - // chooseReturnValueFromCollectionResult - // ); - if (this._isRemoteCollection()) { const result = await this._callMutatorMethodAsync('insertAsync', [doc]); diff --git a/packages/mongo/mongo_livedata_tests.js b/packages/mongo/mongo_livedata_tests.js index d16831deae..1dd498c345 100644 --- a/packages/mongo/mongo_livedata_tests.js +++ b/packages/mongo/mongo_livedata_tests.js @@ -1652,33 +1652,44 @@ _.each( ['STRING', 'MONGO'], function(idGeneration) { // See https://github.com/meteor/meteor/issues/594. testAsyncMulti('mongo-livedata - document with length, ' + idGeneration, [ - function (test, expect) { + function(test, expect) { this.collectionName = Random.id(); if (Meteor.isClient) { - Meteor.call('createInsecureCollection', this.collectionName, collectionOptions); + Meteor.call( + 'createInsecureCollection', + this.collectionName, + collectionOptions + ); Meteor.subscribe('c-' + this.collectionName, expect()); } - }, function (test, expect) { - var self = this; - var coll = self.coll = new Mongo.Collection(self.collectionName, collectionOptions); - - coll.insert({foo: 'x', length: 0}, expect(function (err, id) { - test.isFalse(err); - test.isTrue(id); - self.docId = id; - test.equal(coll.findOne(self.docId), - {_id: self.docId, foo: 'x', length: 0}); - })); }, - function (test, expect) { + async function(test, expect) { var self = this; - var coll = self.coll; - coll.update(self.docId, {$set: {length: 5}}, expect(function (err) { - test.isFalse(err); - test.equal(coll.findOne(self.docId), - {_id: self.docId, foo: 'x', length: 5}); - })); - } + var coll = (self.coll = new Mongo.Collection( + self.collectionName, + collectionOptions + )); + + const id = await coll.insertAsync({ foo: 'x', length: 0 }); + + test.isTrue(id); + self.docId = id; + test.equal(await coll.findOneAsync(self.docId), { + _id: self.docId, + foo: 'x', + length: 0, + }); + }, + async function(test, expect) { + const self = this; + const coll = self.coll; + await coll.updateAsync(self.docId, { $set: { length: 5 } }); + test.equal(await coll.findOneAsync(self.docId), { + _id: self.docId, + foo: 'x', + length: 5, + }); + }, ]); testAsyncMulti('mongo-livedata - document with a date, ' + idGeneration, [