diff options
author | Jacob Evans <jacob.evans@10gen.com> | 2020-05-27 12:28:32 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-06-01 04:15:59 +0000 |
commit | 82fd62e031f46a2c0e919f512df70c4de0b0d151 (patch) | |
tree | b4a8611b1064951293d28e05ab92ef392fa73802 /jstests/noPassthroughWithMongod | |
parent | d00b75bfcac3ac74036ac6c2ceec4e8b42ac93a0 (diff) | |
download | mongo-82fd62e031f46a2c0e919f512df70c4de0b0d151.tar.gz |
SERVER-46737 Support let variables for find command
Diffstat (limited to 'jstests/noPassthroughWithMongod')
-rw-r--r-- | jstests/noPassthroughWithMongod/command_let_variables.js | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/jstests/noPassthroughWithMongod/command_let_variables.js b/jstests/noPassthroughWithMongod/command_let_variables.js index 1b80977f0dd..c5d235dfe68 100644 --- a/jstests/noPassthroughWithMongod/command_let_variables.js +++ b/jstests/noPassthroughWithMongod/command_let_variables.js @@ -196,9 +196,29 @@ assert.commandWorked(db.runCommand({ })); assert.eq(targetColl.aggregate({$match: {$expr: {$eq: ["$var", "INNER"]}}}).toArray().length, 1); +// find +let result = assert + .commandWorked(db.runCommand({ + find: coll.getName(), + let : {target_species: "Song Thrush (Turdus philomelos)"}, + filter: {$expr: {$eq: ["$Species", "$$target_species"]}}, + projection: {_id: 0} + })) + .cursor.firstBatch; +expectedResults = { + Species: "Song Thrush (Turdus philomelos)", + population_trends: [ + {term: {start: 1970, end: 2014}, pct_change: -53, annual: -1.7, trend: "weak decline"}, + {term: {start: 2009, end: 2014}, pct_change: -4, annual: -0.88, trend: "no change"} + ] +}; + +assert.eq(result.length, 1); +assert.eq(expectedResults, result[0]); + // findAndModify assert.commandWorked(coll.insert({Species: "spy_bird"})); -let result = db.runCommand({ +result = db.runCommand({ findAndModify: coll.getName(), let : {target_species: "spy_bird"}, query: {$expr: {$eq: ["$Species", "$$target_species"]}}, |