Avoid invoking mapReduce in complieAliases when database has not been created yet. Fixes #4.
This commit is contained in:
1 parent
914a470116
commit
10be06c619
1 file changed
+7
-3
@@ -85,10 +85,11 @@ createParameterAttributeFinder = (attributeName) ->
|
|||||||
|
|
||||||
|
|
||||||
splitIds = (batches, callback) ->
|
splitIds = (batches, callback) ->
|
||||||
ids = [{}]
|
|
||||||
return callback(ids) if batches == 1
|
|
||||||
db.devicesCollection.count((err, count) ->
|
db.devicesCollection.count((err, count) ->
|
||||||
return callback(ids) if count <= 1000
|
throw err if err
|
||||||
|
return callback(null) if count == 0
|
||||||
|
ids = [{}]
|
||||||
|
return callback(ids) if count <= 1000 or batches == 1
|
||||||
batchSize = Math.floor(count / batches)
|
batchSize = Math.floor(count / batches)
|
||||||
for i in [1 ... batches]
|
for i in [1 ... batches]
|
||||||
ids[i] = {}
|
ids[i] = {}
|
||||||
@@ -158,6 +159,9 @@ compileAliases = (callback) ->
|
|||||||
|
|
||||||
counter = 0
|
counter = 0
|
||||||
splitIds(4, (batches) ->
|
splitIds(4, (batches) ->
|
||||||
|
if not batches?
|
||||||
|
return callback(null, aliases, config.ALIASES_CACHE)
|
||||||
|
|
||||||
for batch in batches
|
for batch in batches
|
||||||
options = {
|
options = {
|
||||||
out : {inline : 1}
|
out : {inline : 1}
|
||||||
|
|||||||
Reference in new issue
Block a user