Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
The UserStamp mixin
'use strict';
const utils = require('./utils');
module.exports = function(Model, bootOptions) {
const options = Object.assign(
{
creatorId: 'creatorId',
required: true,
},
bootOptions
);
Model.dataSource.defineRelations(Model, {
creator: {
type: 'belongsTo',
model: 'user',
foreignKey: options.creatorId,
},
});
Model.beforeRemote('**', utils.addUserInfoToOptions);
Model.observe('before save', utils.addUserInfoToInstance(options));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.