Skip to content

Commit fe81604

Browse files
committed
Revert changes to find
1 parent 74ee861 commit fe81604

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

src/Adapters/Storage/Mongo/MongoCollection.js

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
let mongodb = require('mongodb');
22
let Collection = mongodb.Collection;
3-
import * as transform from './MongoTransform';
43

54
export default class MongoCollection {
65
_mongoCollection:Collection;
@@ -14,28 +13,25 @@ export default class MongoCollection {
1413
// none, then build the geoindex.
1514
// This could be improved a lot but it's not clear if that's a good
1615
// idea. Or even if this behavior is a good idea.
17-
18-
// Depends on the className and schemaController because mongoObjectToParseObject does.
19-
// TODO: break this dependency
2016
find(query, { skip, limit, sort } = {}) {
2117
return this._rawFind(query, { skip, limit, sort })
22-
.catch(error => {
23-
// Check for "no geoindex" error
24-
if (error.code != 17007 && !error.message.match(/unable to find index for .geoNear/)) {
25-
throw error;
26-
}
27-
// Figure out what key needs an index
28-
let key = error.message.match(/field=([A-Za-z_0-9]+) /)[1];
29-
if (!key) {
30-
throw error;
31-
}
18+
.catch(error => {
19+
// Check for "no geoindex" error
20+
if (error.code != 17007 && !error.message.match(/unable to find index for .geoNear/)) {
21+
throw error;
22+
}
23+
// Figure out what key needs an index
24+
let key = error.message.match(/field=([A-Za-z_0-9]+) /)[1];
25+
if (!key) {
26+
throw error;
27+
}
3228

33-
var index = {};
34-
index[key] = '2d';
35-
return this._mongoCollection.createIndex(index)
36-
// Retry, but just once.
37-
.then(() => this._rawFind(query, { skip, limit, sort }));
38-
})
29+
var index = {};
30+
index[key] = '2d';
31+
return this._mongoCollection.createIndex(index)
32+
// Retry, but just once.
33+
.then(() => this._rawFind(query, { skip, limit, sort }));
34+
});
3935
}
4036

4137
_rawFind(query, { skip, limit, sort } = {}) {

0 commit comments

Comments
 (0)