Skip to content
This repository was archived by the owner on Jan 19, 2024. It is now read-only.

Commit 21c63ef

Browse files
committed
fix hook index (type was missing)
1 parent d1eb1c4 commit 21c63ef

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ module.exports = function (schema, options) {
1919
options.index = this.collection.name;
2020
}
2121
if (!options.type) {
22-
options.type = utils.lcFirst(this.modelName);
22+
options.type = utils.lcFirst(this.modelName || this.constructor.modelName);
23+
}
24+
25+
if (!options.index || !options.type) {
26+
throw new Error(options.index ? 'Missing model name to build ES type' : 'Missing collection name to build ES index');
2327
}
2428

2529
if (!options.client) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mongoose-elasticsearch-xp",
3-
"version": "2.0.0",
3+
"version": "2.1.0",
44
"description": "A mongoose plugin that indexes models into elastic search (an alternative to mongoosastic)",
55
"tags": [
66
"mongodb",

0 commit comments

Comments
 (0)