Oriented graph methods with shema and restrictions.
var a = new Mongo.Collection('a');
var a1 = a.insert({ _id: 'a1' });
var a2 = a.insert({ _id: 'a2' );
var b = new Mongo.Collection('b');
b.attachGraph();
b.insertLink(a1, a2); // ~"b1"
var b1 = b.findLinkTo(a2); // { _id: "b1", _source: { id: 'a1', collection: 'a' }, _target: { id: 'a1', collection: 'a' } }
b1.source() // { _id: 'a1' }
()
Attach to the collection, all methods and all helpers.
Add to collection collection.isGraph = true;
.
(source: Document|Ref, target: Document|Ref, customFields: Object, callback?: Function) => id: String
(source: Document|Ref|(id: String), target: Document|Ref|(id: String), query: Object, options: Object) => Document|undefined
collection.findOne.link
(target: Document|Ref|(id: String), query: Object, options: Object) => Document|undefined
(source: Document|Ref|(id: String), query: Object, options: Object) => Document|undefined
(source: Document|Ref|(id: String), target: Document|Ref|(id: String), query: Object, options: Object) => Cursor
(target: Document|Ref|(id: String), query: Object, options: Object) => Cursor
(source: Document|Ref|(id: String), query: Object, options: Object) => Cursor
Used package matb33:collection-hooks.
Available field this.action
containing insert
update
or remove
.
Available fields this.sourceChanged: Boolean
and this.targetChanged: Boolean
.
(handler: (userId, doc, fieldNames, modifier, options) => void)
Wrapper around matb33:collection-hooks .after.update and .after.insert.
(handler: (userId, doc, fieldNames, modifier, options) => void)
Wrapper around matb33:collection-hooks .after.update and .after.remove.
(handler: (userId, doc, fieldNames, modifier, options) => void)
(handler: (userId, doc, fieldNames, modifier, options) => void)
(handler: (userId, doc, fieldNames, modifier, options) => void)
(handler: (userId, doc, fieldNames, modifier, options) => void)
Used package dburles:collection-helpers.
() => Document|undefined
() => Document|undefined
Used package ivansglazunov:restrict.
Add new restriction checks. In the case of operation insert
the arguments fieldNames
and modifier
are not exists. Available argument action
containing insert
update
or remove
.
handler: (userId, doc, fieldNames, modifier, action) => Boolean
collection.allow({
'link': function(userId, doc, fieldNames, modifier, action) {
return true;
},
'link.source': function(userId, doc, fieldNames, modifier, action) {
return true;
},
'link.target': function(userId, doc, fieldNames, modifier, action) {
return true;
},
'unlink': function(userId, doc, fieldNames, modifier, action) {
return true;
},
'unlink.source': function(userId, doc, fieldNames, modifier, action) {
return true;
},
'unlink.target': function(userId, doc, fieldNames, modifier, action) {
return true;
}
});
collection.deny({
'link': function(userId, doc, fieldNames, modifier, action) {
return false;
},
'link.source': function(userId, doc, fieldNames, modifier, action) {
return false;
},
'link.target': function(userId, doc, fieldNames, modifier, action) {
return false;
},
'unlink': function(userId, doc, fieldNames, modifier, action) {
return false;
},
'unlink.source': function(userId, doc, fieldNames, modifier, action) {
return false;
},
'unlink.target': function(userId, doc, fieldNames, modifier, action) {
return false;
}
});
- Add
.after.link.source
,.after.link.target
,.after.unlink.source
,.after.unlink.target
- Add to after handler
this.sourceChanged
andthis.targetChanged
- Rename
.insert.link
argumentquery
tocustomFields