Using mongoose plugins doesn't seem to work
See original GitHub issueI suppose to keep this Issue generic, I don’t seem to be able to add mongoose plugins to Keystone.
I thought I could just access keystone.List('Post').model
to get the native mongoose plugin and therefore specify in my model specification: Post.model.plugin(...);
But I am getting the following error:
TypeError: Object function model(doc, fields, skipId) {
if (!(this instanceof model))
return new model(doc, fields, skipId);
Model.call(this, doc, fields, skipId);
} has no method 'plugin'
Specifically I would love to use the plugin https://github.com/jamescarr/mongoosastic within keystone to provide some powerful search for the frontend. Unfortunately I don’t have any time right now to dig into the issue myself but will try at some point soon. But maybe @JedWatson you know immediately what the issue could be.
Issue Analytics
- State:
- Created 9 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Using mongoose plugins doesn't seem to work #590 - GitHub
I suppose to keep this Issue generic, I don't seem to be able to add mongoose plugins to Keystone. I thought I could...
Read more >Mongoose global plugins not working (ES6) - Stack Overflow
I got it working by up splitting plugins and models into separate files and created an index.js for importing all the plugins.
Read more >Mongoose v6.8.1: FAQ
A. At its core, this issue stems from not connecting to MongoDB. You can use Mongoose before connecting to MongoDB, but you must...
Read more >mongoose-autopopulate
Usage. The mongoose-autopopulate module exposes a single function that you can pass to Mongoose schema's plugin() function. const schema = new mongoose.
Read more >Why does Mongoose remove the key when specified in the ...
... over why my data doesn't seem to be coming from the database. ... Can you also share the commands you use to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For anyone finding this discussion wanting to setup mongoosastic, the bits are here (add mongoosastic to the schema before register), but to put it in code:
In your model (here named ‘Post’):
More info on Mongoosastic options.
Easy. And agree with @Globegitter, ElasticSearch is awesome. Mongoosastic makes it so easy to get your data indexed.
var event = new keystone.List(‘Event’); event.schema.plugin(timeZone,{ paths: [‘event_date’] }); i’m trying to use mongoose timezone plugin but when i’m trying to create a record for events keystone throwing an error Sorry, an error occurred loading the page (500) Cannot read property ‘numAsyncPres’ of undefined can anyone help me to solve this issue?