
Security News
OWASP 2025 Top 10 Adds Software Supply Chain Failures, Ranked Top Community Concern
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.
resource-oriented object-relational mapper for document databases.
Here's the simplest of resources:
var Creature = resourcer.define('creature');
The returned Creature object is a resource constructor, in other words, a function.
Now let's add some properties to this constructor:
Creature.property('diet'); // Defaults to String
Creature.property('vertebrate', Boolean);
Creature.property('belly', Array);
And add a method to the prototype:
Creature.prototype.feed = function (food) {
this.belly.push(food);
};
Now lets instantiate a Creature, and feed it:
var wolf = new(Creature)({
diet: 'carnivor',
vertebrate: true
});
wolf.feed('squirrel');
You can also define resources this way:
var Creature = resourcer.define('creature', function () {
this.property('diet');
this.property('vertebrate', Boolean);
this.property('belly', Array);
this.prototype.feed = function (food) {
this.belly.push(food);
};
});
Resource.propertyResource.property(name, type='string', options={})
Lets define a legs property, which is the number of legs the creature has:
Creature.property('legs', Number);
Note that this form is equivalent:
Creature.property('legs', 'number');
If we wanted to constrain the possible values the property could take, we could pass in an object as the last parameter:
Creature.property('legs', Number, {
required: true,
minimum: 0,
maximum: 8,
assert: function (val) {
return val % 2 === 0;
}
});
Now resourcer won't let Creature instances be saved unless the legs property
has a value between 0 and 8, and is even,
This style is also valid for defining properties:
Creature.property('legs', Number)
.required()
.minimum(0)
.maximum(8)
.assert(function (val) { return val % 2 === 0 });
If you want to access and modify an already defined property, you can do it this way:
Creature.properties['legs'].maximum(6);
Wolf.create({ name: 'Wolverine', age: 68 }, function (err, wolf) {
if (err) { throw new(Error)(err) }
console.log(wolf); // { _id: 42, resource: 'wolf', name: 'Wolverine', age: 68 }
wolf.age ++;
wolf.save(function (err) {
if (! err) console.log('happy birthday ' + wolf.name + '!');
});
});
Wolf.get(42, function (e, wolf) {
if (e) { throw new(Error)(e) }
wolf.update({ fur: 'curly' }, function (e, wolf) {
console.log(wolf.fur); // "curly"
});
});
These methods are available on all user-defined resource constructors,
as well as on the default resourcer.Resource constructor.
Resource.get(id, [callback])Fetch a resource by id.
Resource.update(id, properties, [callback])Update a resource with properties.
Resource.destroy(id, [callback])Destroy a resource by id.
Resource.all([callback])Fetches all resources of this type.
Resource.save(properties, [callback])Resource.create(properties, [callback])These are the prototype methods, available on resource instances
created with the new operator.
Resource.prototype.save([callback])Resource.prototype.update(properties, [callback])Resource.prototype.destroy([callback])Resource.prototype.reload([callback])FAQs
resource-oriented object-relational mapper for document databases
The npm package resourcer receives a total of 1 weekly downloads. As such, resourcer popularity was classified as not popular.
We found that resourcer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.