Throw an error if model factory is not found

This commit is contained in:
Phan An 2017-12-13 00:21:05 +01:00
parent eab3212bb2
commit 5b691d6214

View file

@ -6,6 +6,10 @@ import video from './video'
const models = { artist, album, song, video }
const factory = (model, count = 1, overrides = {}) => {
if (!(model in models)) {
throw new Error(`Model \`${model}\` not found`)
}
if (typeof count === 'object') {
return factory(model, 1, count)
}