 isString    = require 'util-ex/lib/is/type/string'
 debug       = require('debug')('loopback:component:autoMigrate:loadData')
 loopback    = require 'loopback'
+path        = require 'path'
 
 # import data to database from /server/data/ folder
 # need promise to done.

    Promise.reject err
    .asCallback done

  return reject(new TypeError 'The data should be an array.') unless isArray data
  Model = loopback.getModel(Model) if isString Model
  return reject(new TypeError 'Missing Model') unless Model

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

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