1
1
let mongodb = require ( 'mongodb' ) ;
2
2
let Collection = mongodb . Collection ;
3
- import * as transform from './MongoTransform' ;
4
3
5
4
export default class MongoCollection {
6
5
_mongoCollection :Collection ;
@@ -14,28 +13,25 @@ export default class MongoCollection {
14
13
// none, then build the geoindex.
15
14
// This could be improved a lot but it's not clear if that's a good
16
15
// 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
20
16
find ( query , { skip, limit, sort } = { } ) {
21
17
return this . _rawFind ( query , { skip, limit, sort } )
22
- . catch ( error => {
23
- // Check for "no geoindex" error
24
- if ( error . code != 17007 && ! error . message . match ( / u n a b l e t o f i n d i n d e x f o r .g e o N e a r / ) ) {
25
- throw error ;
26
- }
27
- // Figure out what key needs an index
28
- let key = error . message . match ( / f i e l d = ( [ A - Z a - 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 ( / u n a b l e t o f i n d i n d e x f o r .g e o N e a r / ) ) {
21
+ throw error ;
22
+ }
23
+ // Figure out what key needs an index
24
+ let key = error . message . match ( / f i e l d = ( [ A - Z a - z _ 0 - 9 ] + ) / ) [ 1 ] ;
25
+ if ( ! key ) {
26
+ throw error ;
27
+ }
32
28
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
+ } ) ;
39
35
}
40
36
41
37
_rawFind ( query , { skip, limit, sort } = { } ) {
0 commit comments