Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
stork-odm
Advanced tools
Readme
Stork provides a layer of document management over the CouchDB with multitenant support and the use of CouchDB view indexing to support parent/child relationships.
Inspired by resourceful.
var odm = require('stork');
var dburl = 'http://localhost:5984/stork_test'
, User
, BlogPost
, Comment
;
User = odm.deliver('user', function() {
this.sort('lastName', 'firstName');
this.string('firstName');
this.string('lastName', { required: true });
this.string('email', { required: true, format: 'email' });
});
Comment = odm.deliver('comment', function() {
this.string('title', { required: true });
this.string('content');
this.timestamps();
this.ref('author', User, { required: true });
});
BlogPost = odm.deliver('discussion', function() {
this.string('title', { required: true });
this.string('content');
this.bool('isSticky');
this.timestamps();
this.view('byUpdatedOn', ['updatedOn']);
this.ref('author', User, { required: true });
this.composes('comments', Comment);
// DOES NOT EXIST, YET: this.method
this.method('addComment', function (title, content, author) {
var comment = Comment.new({
title: title
, content: content
, author: author
})
;
this.comments.push(comment);
});
// DOES NOT EXIST, YET
this.method('removeComment', function (comment) {
var childIds = this.children.map(function(child) {
return child._id
})
, childIndex = childIds.indexOf(comment._id)
;
if (childIndex < 0) {
return;
}
this.comments.splice(childIndex, 1);
});
});
BlogPost.from(dburl).withComments(function(err, posts) {
posts.forEach(function (post) {
console.log(post);
post.comments.forEach(function (comment) {
console.log('\t', comment);
});
});
});
This section contains a task-based set of instructions on how to use stork
for your CouchDB ODM needs. It models a simple reservation system.
Follow the instructions, below, in Installing.
Yeah, that seems pretty self evident.
var odm = require('stork');
Let's declare an entity that stork knows about. When we declare entities, we provide a name and, if we want, a function that will describe a schema for us. We can define arrays, booleans, children, date/times, numbers, objects with their own schema, references to other documents, strings, timestamps, and views.
stork
uses the schema of the object to provide validation for you. You can save invalid documents to CouchDB, if you'd like. stork
does not judge. stork
just delivers.
var event = odm.stork('event', function() {
this.string('name', { required: true, maxLength: 100 });
this.string('description', { required: true });
this.object('venue', { required: true }, function() {
this.string('url', { format: 'url' });
this.string('name');
this.string('address', { required: true });
this.string('city');
this.string('state');
this.string('zip', { format: /\d{5}/ });
});
this.number('maximumGuests', { required: true });
this.boolean('cancelled');
this.array('rsvps');
this.timestamps();
});
npm install
SKIP_STORK_DB_TESTS=1 ./node_modules/autotest/autotest.js --npm
grunt
and make sure you have no errors either in tests or in jslint.Because we're still developing, this ain't on npm, yet. So, right now, you can run the following commands to include it in your project.
git clone https://github.com/realistschuckle/stork.git
cd stork
npm link
Read more about the npm-link
command.
FAQs
Stork provides a layer of document management over the CouchDB.
The npm package stork-odm receives a total of 2 weekly downloads. As such, stork-odm popularity was classified as not popular.
We found that stork-odm 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.