Create a new service
1- feathers generate service
$ feathers generate service
? What kind of service is it? Mongoose
? What is the name of the service? comments
? Which path should the service be registered on? /comments
? Does the service require authentication? No2- Create validator file
const {Joi} = require('feathers-mongoose-casl');
const getJoiObject = function(withRequired){
const required = withRequired ? 'required' : 'optional';
return Joi.object({
post: Joi.objectId().meta({ type: 'ObjectId', ref: 'roles' })[required](),
text: Joi.string()[required](),
});
};
module.exports = getJoiObject;3- Update comments.model.js
4- comments.service.js
Last updated
Was this helpful?