From 43af2c3dc52b251f4d953228481710e8a0f2a6fd Mon Sep 17 00:00:00 2001 From: Dan Ribbens Date: Thu, 26 Sep 2019 15:23:42 -0400 Subject: [PATCH] mongoose SingleNestedPath compatability added for subdocument queries --- src/plugins/buildQuery.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/buildQuery.js b/src/plugins/buildQuery.js index 5ebfdcca9b..45808a38ba 100644 --- a/src/plugins/buildQuery.js +++ b/src/plugins/buildQuery.js @@ -97,14 +97,14 @@ function parseParam(key, val, model, query, locale) { function parseSchemaForKey(schema, query, keyPrefix, lcKey, val, operator, locale) { let paramType; let key = keyPrefix + lcKey; - let matches = lcKey.match(/(.+)\.(.+)/); if (matches) { // Parse SubSchema if (schema.paths[matches[1]].constructor.name === 'DocumentArray' || schema.paths[matches[1]].constructor.name === 'Mixed') { parseSchemaForKey(schema.paths[matches[1]].schema, `${matches[1]}.`, matches[2], val, operator) - } else if (schema.paths[matches[1]].constructor.name === 'SchemaType') { + } else if (schema.paths[matches[1]].constructor.name === 'SchemaType' || + schema.paths[matches[1]].constructor.name === 'SingleNestedPath') { // This wasn't handled in the original package but seems to work paramType = schema.paths[matches[1]].schema.paths.name.instance; }