Last active
January 15, 2016 18:07
-
-
Save crobinson42/8f7976a6370a40ccefed to your computer and use it in GitHub Desktop.
Sailsjs model association query
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Report | |
.find({where: {users: "562ed24a11ea954b36f20f74" }}) | |
.populate('users') | |
.exec(function (err, reports) { | |
console.log(reports); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
attributes: { | |
users : { | |
collection : 'user', | |
via : 'reports' | |
} | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
attributes: { | |
reports : { | |
collection : 'report', | |
via : 'users' | |
} | |
} | |
}; |
This is not working for me... no results
will answer in gitter
The solution here, advised by Mike McNeil, is to create a junction Model ie: ReportUser
and use that model to reference the association.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is not working for me... no results