JKHeadley / JKHeadley/rest-hapi

Support scope/permissions for individual model properties.

Open
#33 0 comments 2 reactions 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
1.2k
Forks
155
PR merge metrics
No merged PRs in 30d

Description

Example:

```javascript
'use strict';

module.exports = function (mongoose) {
const modelName = "user";
const Types = mongoose.Schema.Types;
const Schema = new mongoose.Schema({
isActive: {
type: Types.Boolean,
default: false
scope: {
updateScope: ['Admin'] //<------only users with 'Admin' scope can update this property
},
allowOnCreate: false
},
email: {
type: Types.String,
unique: true,
index: true,
sparse: true
},
password: {
type: Types.String,
exclude: true,
allowOnUpdate: false
}
}, {collection: modelName});

Schema.statics = {
collectionName: modelName,
routeOptions: {
associations: {
}
}
};

return Schema;
};

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.