@typegoose/typegoose
Version:
Define Mongoose models using TypeScript classes
27 lines • 1.96 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.searchIndex = searchIndex;
exports.SearchIndex = searchIndex;
const constants_1 = require("./internal/constants");
const utils_1 = require("./internal/utils");
const logSettings_1 = require("./logSettings");
/**
* Defines a search index for this Class which will then be added to the Schema.
*
* @param description - The description of the search index to add.
* @example Example:
* ```ts
* @searchIndex({ name: 'descriptionIndex', definition: { mappings: { dynamic: true }}})
* class ClassName {}
* ```
* @remarks Search indices are only supported when connected to MongoDB Atlas.
*/
function searchIndex(description) {
return (target) => {
logSettings_1.logger.info('Adding "%o" Search Indexes to %s', description, (0, utils_1.getName)(target));
const searchIndices = Array.from(Reflect.getOwnMetadata(constants_1.DecoratorKeys.SearchIndex, target) ?? []);
searchIndices.push(description);
Reflect.defineMetadata(constants_1.DecoratorKeys.SearchIndex, searchIndices, target);
};
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VhcmNoSW5kZXhlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9zZWFyY2hJbmRleGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBZ0JBLGtDQU9DO0FBR3VCLGtDQUFXO0FBMUJuQyxvREFBcUQ7QUFDckQsNENBQTJDO0FBQzNDLCtDQUF1QztBQUd2Qzs7Ozs7Ozs7OztHQVVHO0FBQ0gsU0FBZ0IsV0FBVyxDQUFDLFdBQW1DO0lBQzdELE9BQU8sQ0FBQyxNQUFXLEVBQUUsRUFBRTtRQUNyQixvQkFBTSxDQUFDLElBQUksQ0FBQyxrQ0FBa0MsRUFBRSxXQUFXLEVBQUUsSUFBQSxlQUFPLEVBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQztRQUM5RSxNQUFNLGFBQWEsR0FBNkIsS0FBSyxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUMsY0FBYyxDQUFDLHlCQUFhLENBQUMsV0FBVyxFQUFFLE1BQU0sQ0FBQyxJQUFJLEVBQUUsQ0FBQyxDQUFDO1FBQzVILGFBQWEsQ0FBQyxJQUFJLENBQUMsV0FBVyxDQUFDLENBQUM7UUFDaEMsT0FBTyxDQUFDLGNBQWMsQ0FBQyx5QkFBYSxDQUFDLFdBQVcsRUFBRSxhQUFhLEVBQUUsTUFBTSxDQUFDLENBQUM7SUFDM0UsQ0FBQyxDQUFDO0FBQ0osQ0FBQyJ9