diff --git a/dist/RequestValidator.js b/dist/RequestValidator.js index d166a6b..b979640 100644 --- a/dist/RequestValidator.js +++ b/dist/RequestValidator.js @@ -1,5 +1,6 @@ "use strict"; -var MongooseBreadError = require("./MongooseBreadError"), +var mongoose = require("mongoose"), + MongooseBreadError = require("./MongooseBreadError"), _require = require("mongoose"), isValidObjectId = _require.isValidObjectId; function checkRequest(a) { @@ -99,6 +100,13 @@ function checkSchema(a) { }); return b; }, + getSearchableFieldsOfTypeString(b) { + var c = b.filter(function (b) { + var c = a.path(b) instanceof mongoose.Schema.Types.String; + return c || void 0, c; + }); + return c; + }, }; return b; } diff --git a/dist/index.js b/dist/index.js index 3131e29..681571e 100644 --- a/dist/index.js +++ b/dist/index.js @@ -131,9 +131,13 @@ function mongooseBread(a, b) { ), {}, { softDeleteOptions: d } - ); + ), + f = e.searchableFields; if ( - (checkSchema(a).hasMongoosePaginateV2AlreadyInstalled("index.js"), + (f && + f.length && + (e.searchableFields = checkSchema(a).getSearchableFieldsOfTypeString(f)), + checkSchema(a).hasMongoosePaginateV2AlreadyInstalled("index.js"), a.plugin(require("mongoose-paginate-v2")), (a.statics.browse = browseFactory(e)), (a.statics.read = readFactory(e)), @@ -151,17 +155,17 @@ function mongooseBread(a, b) { e.softDelete) ) { checkSchema(a).hasMongooseDeleteAlreadyInstalled("index.js"); - var f = e.softDeleteOptions; - if (((f.overrideMethods = !0), f.indexFields)) { - var g = f.deletedBy, - h = f.requestUserIdPath; - f.deletedBy = g && h && "string" == typeof h; - var i = ["deleted"]; - f.deletedAt && i.push("deletedAt"), - f.deletedBy && i.push("deletedBy"), - (f.indexFields = i); + var g = e.softDeleteOptions; + if (((g.overrideMethods = !0), g.indexFields)) { + var h = g.deletedBy, + i = g.requestUserIdPath; + g.deletedBy = h && i && "string" == typeof i; + var j = ["deleted"]; + g.deletedAt && j.push("deletedAt"), + g.deletedBy && j.push("deletedBy"), + (g.indexFields = j); } - a.plugin(require("mongoose-delete"), f), + a.plugin(require("mongoose-delete"), g), (a.statics.softDelete = softDeleteFactory(e)), (a.statics.rehabilitate = rehabilitateFactory(e)); }