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

Commit

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

Expand Down
4 changes: 4 additions & 0 deletions test/index.js
Expand Up @@ -849,10 +849,14 @@ describe('put', function () {
})

User.once('relation', function (relation) {
assert(relation.id.length > 1)
assert(relation.from == a.primary())
assert(relation.to == b.primary())
assert(relation.attr == 'followers')
assert(relation.action == 'put')
assert(relation.to_model == 'User')
assert(relation.from_model == 'User')
assert(relation.count === 1)
})

User.relation('followers').put(a, b, function (err, relation) {
Expand Down

0 comments on commit c3d8e3a

Please sign in to comment.