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.constpostsValidators=require('../validators/posts.validators.js');const {createModelFromJoi} =require('feathers-mongoose-casl');var mongoose =require('mongoose');constmongooseSchema= var sampleSchema =newmongoose.Schema({ name: { type: String, required:true } });module.exports=function (app) {returncreateModelFromJoi(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