Created
April 19, 2014 05:10
-
-
Save otang/11074749 to your computer and use it in GitHub Desktop.
This file contains 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
query = db.Auction.find | |
where: | |
id: req.params.auction | |
include: [ | |
db.User | |
db.Region | |
db.Section | |
{ model: db.Image, as: 'thumbnail' } | |
{ model: db.Image, as: 'image' } | |
# Seller and seller's membership info | |
{ | |
model: db.User | |
include: | |
model: db.Membership | |
foreignKey: 'user_id' | |
where: | |
group_id: req.group_id | |
} | |
] | |
query.success (auction) -> | |
if not auction then return res.json 404, "Not found" | |
# hacky: move membership from array to obj | |
if auction.user and auction.user.dataValues.membership and auction.user.dataValues.membership.length > 0 | |
auction.user.dataValues.membership = auction.user.dataValues.membership[0] | |
res.json auction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment