Inside the model file, pass also a mongoose schema
src\models\posts.model.js
// posts-model.js - A mongoose model
//
// See http://mongoosejs.com/docs/models.html
// for more of what you can do here.
const postsValidators = require('../validators/posts.validators.js');
const {createModelFromJoi} = require('feathers-mongoose-casl');
var mongoose = require('mongoose');
const mongooseSchema = var sampleSchema = new mongoose.Schema({ name: { type: String, required: true } });
module.exports = function (app) {
return createModelFromJoi(app, 'posts', postsValidators, mongooseSchema);
};
Why we use JOI
You need to create a validator file for each mongoose service in your app
The file need to export a function that will return a JOI schema
With joigoose we will convert this schema to mongoose schema
With joi2jso we will convert this scheme to JSON schema for the dashboard