Mongoose provides a straight-forward, schema-based solution to modeling your application data and includes built-in type casting, validation, query building, business logic hooks and more, out of the box.
Questions tagged [mongoose-plugins]
79 questions
1
vote
0 answers
Why is a Mongoose find operation slower than with the raw MongoDB driver?
I am using Mongoose for the first time in an application and I am observing much slower find() or count() operations compared to the raw MongoDB driver. I am trying to understand why. Here are the NodeJS npms used:
"mongodb": "^2.2.33",
…

Maxime Asselin
- 484
- 1
- 6
- 14
1
vote
1 answer
Mongoose plugin with preselected filter
Is it possible to create a mongoose plugin that in every query it will add a standard filter?
I want every time a make a User.find() or User.findOne() or User.update() or User.delete() etc... to include everytime this filter { activated: true }

Michalis
- 6,686
- 13
- 52
- 78
1
vote
0 answers
Auto increment field in mongodb
I am trying to create an auto increment field in mongodb but am getting an error.I am new to mongodb so can anyone help me with the error? My code is:
var express = require('express');
var fs = require('fs');
var mongoose = require('mongoose');
var…

Ramya
- 51
- 7
1
vote
1 answer
Header files for Mongoose' 'plugin' method (extending via .methods and .statics)
I'm trying to create Typescript header files for a script that extends my Mongoose-model by using the .plugin method. Current signature from Mongoose header-files:
export class Schema {
// ...
plugin(plugin: (schema: Schema, options?: Object)…

Robert de W
- 316
- 8
- 24
1
vote
1 answer
Deep populate self referencing schema in mongoose
I have an self referencing employee schema in mongoose.
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var Employee = new Schema({
name: String,
description: {
type: String,
default: 'No description'
},
manager: {
…

SharpCoder
- 18,279
- 43
- 153
- 249
1
vote
1 answer
Text search in MongoDB, keyword search
I'm trying to do a keyword search in my mongoDB database. In the mongoDB console:
db.logs.find({$text: {$search: 'key1'}})
gives the correct result. But when I use mongoose-text-search on my nodejs controller I get an error. This is the definition…

cauchi
- 1,463
- 2
- 17
- 45
1
vote
1 answer
How to specify custom dev/prefix in a Keystone LocalFile field
I would like to use the same value generated from the autokey plugin in the keystone.List constructor in the schema object I later pass to List.add.
Here's more precisely what I'm trying to do:
var Thing = new keystone.List('Thing', {
autokey: {…

jesse_ae
- 11
- 1
1
vote
0 answers
Instance Method for array of mongoose subdocuments
I have a mongoose schema like
var userSchema = new mongoose.Schema({
friends: [String]
});
var User = mongoose.model('User', userSchema);
var alice = new User({friends: ['bob']});
and I would like to attach an instance method to the friends…

andrenarchy
- 448
- 3
- 12
1
vote
0 answers
Load more records (Listview) on reaching list end
I have requirement where in my listview should display the next 10 values by reading from the server when a user reaches the end of the list on the screen scroll.
I am using "volley" to get the data from the server asynchronously. My server code is…

MobileAppRocker
- 33
- 4
1
vote
1 answer
Adding field in Mongoose plugin gives "TypeError: Invalid value for schema path `CreatedBy.type`"
I'm trying to make a CreatedBy Mongoose plugin, but when trying to use the ObjectId as the field type it gives me ("account" is another defined collection already):
TypeError: Invalid value for schema path `CreatedBy.type`
& here is the plugin…

AbdelHady
- 9,334
- 8
- 56
- 83
1
vote
0 answers
Sub documents inheritance in mongoose and mongoose-schema-extend
I have tried to implement inheritance for mongoDB sub document using mongoose-schema-extend, and later with mongoose itself.
The basic requirement is to define additional properties in inheriting class and get them on DB- this works fine in both…

Tovi
- 41
- 4
1
vote
1 answer
Mongo: Index on $exists of field
I have the following mongoose schema:
var dataSchema = new Schema({
owner: { type: Schema.ObjectId, ref: 'User' },
time : { type: Date, default: Date.now },
eventCount:Number
});
For some dataObjects the eventCount is defined…

Jacob Horbulyk
- 2,366
- 5
- 22
- 34
1
vote
1 answer
Mongoose search produces cryptic error
I'm using the Mongoose-Text-Search plugin (https://github.com/aheckmann/mongoose-text-search) to search through my mongodb database, but I'm getting a really confusing error message I've never seen before.
error: name=MongoError, ok=0, errmsg=error…

pandringa
- 358
- 1
- 3
- 9
1
vote
1 answer
New version when updating an entry using mongoose and mongoose-version
I am trying to keep a track of all the revisions in some documents in a mongo database using mongoose. For this reason I decided to go with the plugin mongoose-version.
When I create a new document and add it to the database I can see that a version…

MightyMouse
- 13,208
- 8
- 33
- 43
1
vote
1 answer
passport mongoose Object # has no method 'authenticate' yet I can see the method
I am running into an issue that doesn't make sense and can't figure out hoping someone can assist.
I am using a few mongoose plugins and now trying to integrate passport as well. I have added the passport-local-mongoose plugin as shown below, but I…

Kris
- 89
- 1
- 7