1.0.1 • Published 3 years ago

@addaleax/test-mongosh-snippet-mock-collection v1.0.1

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
3 years ago

mock-collection

Provide a fake read-only collection based on input documents.

> mockCollection([{ field: 1 },{ field: 2},{ field: 3 }])
> coll.find({ field: {$gt:2} }, { _id: 1 })
[ { _id: ObjectId("6079840f2454d2cd1073ba6c") } ]
> coll.mapReduce(function() { emit('fieldValue', this.field); },
...              function(key, values) { return key + values.join(','); },
...              { out: { inline: 1 } })
{ results: [ { _id: 'fieldValue', value: 'fieldValue1,2,3' } ], ok: 1 }
1.0.1

3 years ago

1.0.0

3 years ago