brutaljs
Version:
BrutalJS ========
13 lines (11 loc) • 401 B
text/coffeescript
_ = require('lodash')
path = require('path')
glob = require("glob")
mongoose = require('mongoose')
Schema = mongoose.Schema
module.exports = _.map(glob.sync("./models/**/*"), (fileName) ->
withoutExt = path.basename(fileName, '.js')
withoutExt = path.basename(withoutExt, '.coffee')
model = new Schema(require(path.join('../', fileName)), {versionKey: false})
mongoose.model(withoutExt, model)
)