Skip to content

Commit d31883b

Browse files
committed
feat(mongo): add more operations
1 parent 909dedf commit d31883b

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

lib/instrumentations/mongodb.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,29 @@ var Shimmer = require('../utils/shimmer')
22
var consts = require('../consts')
33

44
var COLLECTION_OPERATIONS = [
5-
'find',
6-
'findOne'
5+
'aggregate',
6+
'count',
7+
'deleteMany',
8+
'deleteOne',
9+
'distinct',
10+
'findAndModify',
11+
'findAndRemove',
12+
'findOne',
13+
'findOneAndDelete',
14+
'findOneAndReplace',
15+
'findOneAndUpdate',
16+
'geoHaystackSearch',
17+
'geoNear',
18+
'group',
19+
'insert',
20+
'insertMany',
21+
'insertOne',
22+
'mapReduce',
23+
'remove',
24+
'save',
25+
'update',
26+
'updateMany',
27+
'updateOne'
728
]
829

930
module.exports = function (mongodb, agent) {
@@ -63,3 +84,5 @@ module.exports = function (mongodb, agent) {
6384

6485
return mongodb
6586
}
87+
88+
module.exports._COLLECTION_OPERATIONS = COLLECTION_OPERATIONS

lib/instrumentations/mongodb.spec.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ var expect = require('chai').expect
44
var wrapper = require('./mongodb')
55
var Shimmer = require('../utils/shimmer')
66

7-
var COLLECTION_OPERATIONS = [
8-
'find',
9-
'findOne'
10-
]
11-
127
describe('The mongodb wrapper module', function () {
138
it('should wrap collection\'s operations', function () {
149
var shimmerWrapStub = this.sandbox.stub(Shimmer, 'wrap')
@@ -23,7 +18,7 @@ describe('The mongodb wrapper module', function () {
2318
expect(shimmerWrapStub).to.have.been.calledWith(
2419
fakeMongo.Collection.prototype,
2520
'mongodb.Collection.prototype',
26-
COLLECTION_OPERATIONS
21+
wrapper._COLLECTION_OPERATIONS
2722
)
2823
})
2924

0 commit comments

Comments
 (0)