yoitsro/joigoose

is it possible to ignore fields in Joi object's .meta() area?

Closed this issue · 0 comments

I'm using Joi models and using this library to pass them into mongoose, and another library joi-to-swagger to turn my Joi models into definitions - to get references via that library I need to have something like:

var schema = Joi.object.keys().meta({className:'desiredRef'})

but joigoose tries to put that into a model and I get this error from mongoose:

TypeError: Undefined type `Address` at `className`
  Did you try nesting Schemas? You can only nest using refs or arrays.
    at Function.Schema.interpretAsType (/Users/paul42/code/cb-api/node_modules/mongoose/lib/schema.js:688:11)
    at Schema.path (/Users/paul42/code/cb-api/node_modules/mongoose/lib/schema.js:563:29)
    at Schema.add (/Users/paul42/code/cb-api/node_modules/mongoose/lib/schema.js:445:12)
    at new Schema (/Users/paul42/code/cb-api/node_modules/mongoose/lib/schema.js:99:10)
    at Mongoose.model (/Users/paul42/code/cb-api/node_modules/mongoose/lib/index.js:335:14)
    at _.each.value (/Users/paul42/code/cb-api/lib/startup/models.js:20:39)
    at arrayEach (/Users/paul42/code/cb-api/node_modules/lodash/lodash.js:537:11)
    at Function.forEach (/Users/paul42/code/cb-api/node_modules/lodash/lodash.js:9359:14)
    at Object.<anonymous> (/Users/paul42/code/cb-api/lib/startup/models.js:17:3)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)

is there any easy way to pluck the meta value off the Joi object or clear it out so I can pass the Joi object to Joigoose second

Thanks,
Paul