diff --git a/src/find.js b/src/find.js index 1f8c746..97a910b 100644 --- a/src/find.js +++ b/src/find.js @@ -65,11 +65,12 @@ module.exports = async function(collection, params) { ? COLLECTION_METHODS.FIND_AS_CURSOR : COLLECTION_METHODS.FIND; - const query = collection[findMethod]({ $and: [cursorQuery, params.query] }, params.fields); - // Required to support native mongodb 3+ and keep the backward compatibility with version 2 - if (findMethod === COLLECTION_METHODS.FIND) { - query.project(params.fields); + let query; + if (findMethod === COLLECTION_METHODS.FIND_AS_CURSOR) { + query = collection[findMethod]({ $and: [cursorQuery, params.query] }, params.fields); + } else { + query = collection[findMethod]({ $and: [cursorQuery, params.query] }).project(params.fields); } /** diff --git a/test/support/db.js b/test/support/db.js index 755d70e..ac046a7 100644 --- a/test/support/db.js +++ b/test/support/db.js @@ -16,12 +16,7 @@ async function db(mongod, driver = null) { db: await mongoist(uri), }; } - const [client, dbName] = await Promise.all([ - MongoClient.connect(uri, { - useUnifiedTopology: true, - }), - mongod.getDbName(), - ]); + const [client, dbName] = await Promise.all([MongoClient.connect(uri), mongod.getDbName()]); return { db: client.db(dbName), client,