File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -145,8 +145,9 @@ module.exports = function (source) {
145145 // GET /:resource/:id
146146 function show ( req , res , next ) {
147147 var _embed = req . query . _embed
148+ var id = utils . toNative ( req . params . id )
148149 var resource = db ( req . params . resource )
149- . get ( utils . toNative ( req . params . id ) )
150+ . get ( id )
150151
151152 if ( resource ) {
152153 // Clone resource to avoid making changes to the underlying object
@@ -156,12 +157,15 @@ module.exports = function (source) {
156157
157158 // Embed other resources based on resource id
158159 _embed . forEach ( function ( otherResource ) {
159- if ( otherResource && otherResource . trim ( ) . length > 0 ) {
160- // Skip non-existent collections
161- if ( ! db . object [ otherResource ] ) return
160+
161+ if ( otherResource
162+ && otherResource . trim ( ) . length > 0
163+ && db . object [ otherResource ] ) {
162164 var query = { }
163- query [ req . params . resource + 'Id' ] = req . params . id
165+ var prop = pluralize . singular ( req . params . resource ) + 'Id'
166+ query [ prop ] = id
164167 resource [ otherResource ] = db ( otherResource ) . where ( query )
168+
165169 }
166170 } )
167171
You can’t perform that action at this time.
0 commit comments