   .then (results)->
     debug Model.modelName + ': total ' + results.length + ' data created.'
     return results
+  .catch (err)->
+    err.name = vFile + ':' + err.name
+    throw err
   .asCallback done

isString    = require 'util-ex/lib/is/type/string'
debug       = require('debug')('loopback:component:autoMigrate:loadData')
loopback    = require 'loopback'

# import data to database from /server/data/ folder
# need promise to done.

    Promise.reject err
    .asCallback done

  vFile = path.basename(data.$cfgPath)
  return reject(new TypeError '%s: The data should be an array.', vFile) unless isArray data
  Model = loopback.getModel(Model) if isString Model
  return reject(new TypeError '%s: Missing Model', vFile) unless Model

  Promise.map data, (item)->
    Model.create item
