Spaces:
Runtime error
Runtime error
Download static/node_modules/mongoose/lib/schema/operators/text.js from kaab4321/NarrativeFlow: direct link, hf CLI and curl.
- Browser
- Download file 1.14 kB
-
https://huggingface.co/spaces/kaab4321/NarrativeFlow/resolve/main/static/node_modules/mongoose/lib/schema/operators/text.js
- Command line
-
hf download hf://spaces/kaab4321/NarrativeFlow/static/node_modules/mongoose/lib/schema/operators/text.js
-
curl -L -o text.js https://huggingface.co/spaces/kaab4321/NarrativeFlow/resolve/main/static/node_modules/mongoose/lib/schema/operators/text.js
1.14 kB
| ; | |
| const CastError = require('../../error/cast'); | |
| const castBoolean = require('../../cast/boolean'); | |
| const castString = require('../../cast/string'); | |
| /** | |
| * Casts val to an object suitable for `$text`. Throws an error if the object | |
| * can't be casted. | |
| * | |
| * @param {Any} val value to cast | |
| * @param {String} [path] path to associate with any errors that occured | |
| * @return {Object} casted object | |
| * @see https://www.mongodb.com/docs/manual/reference/operator/query/text/ | |
| * @api private | |
| */ | |
| module.exports = function(val, path) { | |
| if (val == null || typeof val !== 'object') { | |
| throw new CastError('$text', val, path); | |
| } | |
| if (val.$search != null) { | |
| val.$search = castString(val.$search, path + '.$search'); | |
| } | |
| if (val.$language != null) { | |
| val.$language = castString(val.$language, path + '.$language'); | |
| } | |
| if (val.$caseSensitive != null) { | |
| val.$caseSensitive = castBoolean(val.$caseSensitive, | |
| path + '.$castSensitive'); | |
| } | |
| if (val.$diacriticSensitive != null) { | |
| val.$diacriticSensitive = castBoolean(val.$diacriticSensitive, | |
| path + '.$diacriticSensitive'); | |
| } | |
| return val; | |
| }; | |