             callback null, tempRes
 
         resultData = []
-        wantedOrder = []
-        collections = {}
-        for result in results
-          obj = result.content.data
-          collections[obj.name] ||= []
-          collections[obj.name].push(obj.id)
-          wantedOrder.push({id: obj.id, collection: obj.name, idx: obj.id+'_'+obj.name})
+        {collections, wantedOrder} = @getIdsFromAResultSet _.map(results, (e)->e.content.data)
         @fetchObjectsFromMongo collections, wantedOrder, (err, dbObjects)->
           for dbObj in dbObjects
             collectRelations dbObj
-          #callback err, dbObjects
 
 
   objectify = (incomingObjects, callback)->

      }
      collectObjects({klass:klass, selector:selector, modelName:modelName})

  runQuery:(query, options, callback)->
    {startDate, client} = options
    if options.group?
      {groupName, groupId} = options.group

    @db.query query, {}, (err, results)=>
      tempRes = []
      if err 
        callback err
      else if results.length is 0 then callback null, []
      else
        collectRelations = race (i, res, fin)=>

_ = require 'underscore'
neo4j = require "neo4j"
{race} = require 'sinkrow'
{Base, ObjectId, race} = require 'bongo'
