3

I am using expressjs with sequalize ORM. My user model is some what like

module.exports = function (sequelize, DataTypes) {
 var User = sequelize.define('user', {
    userName: {
      type: DataTypes.STRING
    },
    isAdmin: {
      type: DataTypes.Boolean
    }
   })
  }

but I dont want to allow the request to set isAdmin to be set to true or false on POST/PUT. But i want isAdmin on get request.

I know about excludeAttributes property but it removes the fields on GET request only.

FastTurtle
  • 1,747
  • 11
  • 15

1 Answers1

1

You need to set the readOnlyAttributes. This feature is yet not included in published release. However you can use it by changing your epilogue version to dchester/epilogue#master in package.json. Sample code might look like

var rest = require('epilogue')
var userResource = rest.resource({
   model: DB.User,
   readOnlyAttributes: ['isAdmin']
});

See this Pr.

Satyajeet
  • 2,004
  • 15
  • 22