base-domain
Version:
simple module to help build Domain-Driven Design
56 lines (40 loc) • 1.32 kB
text/coffeescript
'use strict'
DomainError = require './lib/domain-error'
FixtureLoader = require './fixture-loader'
debug = null
###*
load data from directory and generates fixtures
only available in Node.js
Fixture
base-domain
###
class Fixture
###*
{Object} [options]
{String|Array} [options.dirname='./fixtures'] director(y|ies) to have fixture files. /data, /tsvs should be included in the directory.
{String} [options.debug] if true, shows debug log
###
constructor: (, options = {}) ->
debugMode = options.debug ? !!.debug
if debugMode
require('debug').enable('base-domain:fixture')
debug = require('debug')('base-domain:fixture')
=
if options.dirname?
if Array.isArray options.dirname
options.dirname
else
[ options.dirname ]
else
[ __dirname + '/fixtures' ]
###*
inserts data to datasource
insert
{Array} names list of fixture models to insert data
{Promise(EntityPool)}
###
insert: (names) ->
new FixtureLoader(, ).load(async: true, names: names)
module.exports = Fixture