
Security News
AI Agent Lands PRs in Major OSS Projects, Targets Maintainers via Cold Outreach
An AI agent is merging PRs into major OSS projects and cold-emailing maintainers to drum up more work.
fendjs-model
Advanced tools
Minimalistic extensible model component for Fend.js.
Create a new model with the given name.
var Modeler = require('fendjs-model');
var User = Modeler('User');
Use the given plugin fn() on all model.
var Modeler = require('fendjs-model');
Modeler.use(function (Model) {
Model.attr('created_at', { type: 'date' });
Model.attr('updated_at', { type: 'date' });
});
Define an attribute name with optional meta data object.
var Modeler = require('fendjs-model');
var Post = Modeler('Post')
.attr('id')
.attr('title')
.attr('body')
.attr('created_at')
.attr('updated_at')
With meta data used by plugins:
var Modeler = require('fendjs-model');
var Post = Modeler('Post')
.attr('id', { required: true, type: 'number' })
.attr('title', { required: true, type: 'string' })
.attr('body', { required: true, type: 'string' })
.attr('created_at', { type: 'date' })
.attr('updated_at', { type: 'date' })
Add validation fn().
Use the given plugin fn().
var Modeler = require('fendjs-model');
var Post = Modeler('Post')
Post.use(function (Model) {
Model.attr('created_at', { type: 'date' });
Model.attr('updated_at', { type: 'date' });
});
Get id and invoke fn(err, model).
Get all and invoke fn(err, model).
Remove all and invoke fn(err).
"Getter" function generated when Model.attr(name) is called.
var Post = Modeler('Post')
.attr('title')
.attr('body')
var post = new Post;
post.title('Ferrets')
post.body('Make really good pets')
"Setter" function generated when Model.attr(name) is called.
var Post = Modeler('Post')
.attr('title')
.attr('body')
var post = new Post({ title: 'Cats' });
post.title()
// => "Cats"
post.title('Ferrets')
post.title()
// => "Ferrets"
(name, value, previousValue).(value, previousValue).post.on('change', function(name, val, prev){
console.log('changed %s from %s to %s', name, prev, val)
})
post.on('change title', function(val, prev){
console.log('changed title')
})
Get / set the primary key.
Returns true if the model is unsaved.
Return a JSON representation of the model (its attributes).
Check if attr is non-null.
Get attr's value.
Set multiple attrs.
user.set({ name: 'Tobi', age: 2 })
Check if the model is "dirty" and return an object of changed attributes. Optionally check a specific attr and return a Boolean.
Define error msg for attr.
Run validations and check if the model is valid.
user.isValid()
// => false
user.errors
// => [{ attr: ..., message: ... }]
Save or update and invoke the given callback fn(err).
var user = new User({ name: 'Tobi' })
user.save(function(err){
})
Emits "save" when complete.
Destroy and invoke optional fn(err).
Emits "destroy" when successfully deleted.
$ npm install
$ make test
See the LICENSE.
FAQs
Elegant data models for Fend.js
We found that fendjs-model demonstrated a not healthy version release cadence and project activity because the last version was released 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.

Security News
An AI agent is merging PRs into major OSS projects and cold-emailing maintainers to drum up more work.

Research
/Security News
Chrome extension CL Suite by @CLMasters neutralizes 2FA for Facebook and Meta Business accounts while exfiltrating Business Manager contact and analytics data.

Security News
After Matplotlib rejected an AI-written PR, the agent fired back with a blog post, igniting debate over AI contributions and maintainer burden.