json-server
Advanced tools
Comparing version 0.7.11 to 0.7.12
{ | ||
"name": "json-server", | ||
"version": "0.7.11", | ||
"version": "0.7.12", | ||
"description": "Serves JSON files through REST routes.", | ||
@@ -5,0 +5,0 @@ "main": "./src/index.js", |
@@ -148,6 +148,9 @@ var express = require('express') | ||
var _embed = req.query._embed | ||
var id = utils.toNative(req.params.id) | ||
var resource = db(req.params.resource) | ||
.get(utils.toNative(req.params.id)) | ||
.get(id) | ||
if (resource) { | ||
// Clone resource to avoid making changes to the underlying object | ||
resource = _.cloneDeep(resource) | ||
// Always use an array | ||
@@ -158,6 +161,11 @@ _embed = _.isArray(_embed) ? _embed : [_embed] | ||
_embed.forEach(function (otherResource) { | ||
if (otherResource && otherResource.trim().length > 0) { | ||
if (otherResource | ||
&& otherResource.trim().length > 0 | ||
&& db.object[otherResource]) { | ||
var query = {} | ||
query[req.params.resource + 'Id'] = req.params.id | ||
var prop = pluralize.singular(req.params.resource) + 'Id' | ||
query[prop] = id | ||
resource[otherResource] = db(otherResource).where(query) | ||
} | ||
@@ -164,0 +172,0 @@ }) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34680
802