![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
nodee-model
Advanced tools
Readme
Sometimes your application is not a simple to-do list and you need to write complex business logic. Rather than strictly predefined CRUD methods and hooks, nodee-model is a set of tools which you can use to write your own logic, data sources and reusable behaviours.
npm install nodee-model
var Model = require('nodee-model');
/*
* create employee model, which:
* 1. is stored in mongo database
* 2. is in tree structure
* 3. is orderable
* 4. can handle process of changing job - it is not just a simple update,
* it has to be confirmed by HR department
*/
var Employee = Model.define('Employee', [ 'MongoDataSource', 'Orderable', 'Tree' ], {
name:{ isString:true },
surname:{ isString:true },
salary:{ isNumber:true, round:2 },
job:{ isIn:[ 'project_manager', 'sales', 'support'] },
jobConfirmed:{ isBool:true },
// address as submodel
address: { model: Model('Address') },
// or array of submodels
addresses: { arrayOf: Model('Address') }
});
// define connection details by extending inherited defaults
Employee.extendDefaults({
connection:{
host: 'localhost',
port: 27017,
database:'myapp',
collection:'employees'
}
});
// now, add hookable method
Employee.prototype.changeJob = Employee.wrapHooks('changeJob', function(newJob, cb){
var employee = this;
employee.job = newJob;
employee.jobConfirmed = false;
employee.update(cb);
});
// register "beforeChangeJob" listener
Employee.on('beforeChangeJob', function(next){
// notify HR department
next();
});
// init model, this will ensure indexes or do some work to init datastore
Employee.init();
// now we can get employee and change his job
Employee.collection().find({ name:'Chuck', surname:'Norris' }).one(function(err, employee){
employee.changeJob('super_agent', function(err){
// job changed, and HR department was notified
// (but I am sure they can't change Chuck's job - nobody can :)
});
});
// if you need to define a new type of employee, just inherit it from Employee.
// It will inherit all methods including registered events like "beforeJobChange".
var SuperEmployee = Model.define('SuperEmployee', ['Employee']);
FAQs
Advanced, database agnostic ODM
We found that nodee-model demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.