Make find() in MongoStorageAdapter
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
let mongodb = require('mongodb');
|
let mongodb = require('mongodb');
|
||||||
let Collection = mongodb.Collection;
|
let Collection = mongodb.Collection;
|
||||||
|
import * as transform from './MongoTransform';
|
||||||
|
|
||||||
export default class MongoCollection {
|
export default class MongoCollection {
|
||||||
_mongoCollection:Collection;
|
_mongoCollection:Collection;
|
||||||
@@ -13,6 +14,9 @@ export default class MongoCollection {
|
|||||||
// none, then build the geoindex.
|
// none, then build the geoindex.
|
||||||
// This could be improved a lot but it's not clear if that's a good
|
// This could be improved a lot but it's not clear if that's a good
|
||||||
// idea. Or even if this behavior is a good idea.
|
// idea. Or even if this behavior is a good idea.
|
||||||
|
|
||||||
|
// Depends on the className and schemaController because mongoObjectToParseObject does.
|
||||||
|
// TODO: break this dependency
|
||||||
find(query, { skip, limit, sort } = {}) {
|
find(query, { skip, limit, sort } = {}) {
|
||||||
return this._rawFind(query, { skip, limit, sort })
|
return this._rawFind(query, { skip, limit, sort })
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
@@ -31,7 +35,7 @@ export default class MongoCollection {
|
|||||||
return this._mongoCollection.createIndex(index)
|
return this._mongoCollection.createIndex(index)
|
||||||
// Retry, but just once.
|
// Retry, but just once.
|
||||||
.then(() => this._rawFind(query, { skip, limit, sort }));
|
.then(() => this._rawFind(query, { skip, limit, sort }));
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
_rawFind(query, { skip, limit, sort } = {}) {
|
_rawFind(query, { skip, limit, sort } = {}) {
|
||||||
|
|||||||
Reference in New Issue
Block a user