Security News
cURL Project and Go Security Teams Reject CVSS as Broken
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
backbone-rel
Advanced tools
Relationships between Backbone models in the flavor of MongoDB's document references and embeddings
backbone-rel extends Backbone by two concepts that allow applications to model relationships between models: references and embeddings. These concepts are inspired by the MongoDB data modeling in terms of embedded and referenced documents (http://docs.mongodb.org/manual/core/data-modeling-introduction/).
A reference describes a relationship between two model classes (A and B) in terms of a unidirectional link or pointer from one instance of A to one or many instances of B. The reference is defined on the referencing object using the ID of the referenced object.
var User = Backbone.Model.extend({});
var LikeCollection = Backbone.Collection.extend({
model: Like
});
var Comment = Backbone.Model.extend({
references: {
author: User, // to-one reference
likes: LikeCollection // to-many reference
}
});
References work especially well in conjunction with https://github.com/disqus/backbone.uniquemodel. If you set up a reference to a model class tracked by backbone.uniquemodel, a referenced model instance will automatically be resolved to the right instance in the unique model cache.
var User = UniqueModel( Backbone.Model.extend({}), "User" );
var Comment = Backbone.Model.extend({
references: {
author: User
}
});
var user = new User({ id: 1, name: "John Doe" });
var comment = new Comment({ authorId: 1 });
assert(comment.get("user") === user); // the referenced author has been resolved to the unique user instance
An embedded object lives in its parent.
The URL for the API endpoint of the embedded object is built based on the parent model's URL by appending the embedded object's "urlSuffix" property.
Alternatively, the embedded object can be managed entirely through its parent, meaning that it does not have a dedicated URL endpoint but its JSON representation is inlined in the parent JSON.
var MetaData = Backbone.Model.extend({});
var CommentCollection = Backbone.Collection.extend({
model: Comment
});
var Post = Backbone.Model.extend({
embeddings: {
meta: MetaData, // to-one embedding
comments: CommentCollection // to-many embedding
}
})
This can be deactivated using the "autoFetchRelated"
FAQs
Relationships between Backbone models in the flavor of MongoDB's document references and embeddings
We found that backbone-rel demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.