Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
pass from_obj and to_obj to the relation event
Browse files Browse the repository at this point in the history
  • Loading branch information
sergioramos committed Dec 11, 2013
1 parent c3d8e3a commit c77c30f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "modella-level-relations",
"version": "1.5.4",
"version": "1.6.0",
"description": "levelup based modella relations",
"keywords": [
"modella",
Expand Down
8 changes: 6 additions & 2 deletions src/relation.js
Expand Up @@ -249,7 +249,9 @@ relation.prototype.put = function (from, to, fn) {
if(!err) self.model.emit('relation', xtend(rel, {
action: 'put',
attr: self.attr,
from_model: self.model.modelName
from_model: self.model.modelName,
from_obj: from,
to_obj: to
}))
}

Expand Down Expand Up @@ -318,7 +320,9 @@ relation.prototype.del = function (from, to, fn) {
action: 'del',
attr: self.attr,
from: from.primary(),
to: to.primary()
to: to.primary(),
from_obj: from,
to_obj: to
})
}

Expand Down
4 changes: 4 additions & 0 deletions test/index.js
Expand Up @@ -856,6 +856,8 @@ describe('put', function () {
assert(relation.action == 'put')
assert(relation.to_model == 'User')
assert(relation.from_model == 'User')
assert(relation.to_obj == b)
assert(relation.from_obj == a)
assert(relation.count === 1)
})

Expand Down Expand Up @@ -1059,6 +1061,8 @@ describe('del', function () {
assert(relation.to === b.primary())
assert(relation.attr === 'followers')
assert(relation.action === 'put')
assert(relation.from_obj === a)
assert(relation.to_obj === b)
done()
})

Expand Down

0 comments on commit c77c30f

Please sign in to comment.