 
 module.exports = class JMachine extends Module
 
-  { ObjectId, signature } = require 'bongo'
+  { ObjectId, signature, daisy } = require 'bongo'
 
   @trait __dirname, '../../traits/protected'
   {permit} = require '../group/permissionset'

      static            :
        one             :
          (signature String, Function)

    permissions         :
      'list machines'   : ['member']

    schema              :



      JMachine.one selector, (err, machine)->
        callback err, machine

  reviveUsers: permit 'populate users',

  success: (client, callback)->

    JUser = require '../user'

    accounts = []
    queue    = []

    (@users ? []).forEach (_user)->
      queue.push -> JUser.one _id: _user.id, (err, user)->
        if not err? and user
          user.fetchOwnAccount (err, account)->
            if not err? and account?
              accounts.push account
            queue.next()
        else
          queue.next()

    queue.push =>
      callback null, accounts

    daisy queue
