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
2
votes
1 answer
Auto increment plugin nextCount not found
I am using the mongoose-auto-increment plugin and I am using TypeScript Node.js and I have installed the needed typed definitions but when I try to get the next count of the auto increment, I get this
Property 'nextCount' does not exist on type…

mega-crazy
- 838
- 2
- 17
- 36
2
votes
2 answers
Creating a Mongoose plugin that supports callbacks AND promises
I have a Mongoose plugin that currently only supports callbacks, I plan on possibly publishing it to npmjs, but I first wanted to make sure that it works just like the existing Mongoose functions/methods, which support callbacks and some built in…

Justin
- 1,959
- 5
- 22
- 40
2
votes
0 answers
mongoose-attachments-aws2js upload directory
I have a schema for attachments:
var mongoose = require('mongoose');
var s3 = require('./config/secrets').s3;
var provider = require('mongoose-attachments-aws2js');
var attachments =…

alivanov
- 99
- 6
2
votes
0 answers
Call to a static method to a schema inside a plugin in Mongoose
I write a plugin that do :
module.exports = function (schema, options) {
schema.statics.customFunction = function (criteria) {
// Code
};
};
And here is my Schema :
var customPlugin = require('./plugin');
var customSchema = new…

Julien Deruere
- 770
- 1
- 7
- 11
1
vote
1 answer
passport.authenticate not authenticating the user
I am trying to register and authenticate a user using passport-local and passport-local-mongoose but the user is not getting authenticated. I do not want to downgrade my mongoose version.
This is the code for registering and authenticating a user to…

PRAKS
- 11
- 3
1
vote
1 answer
Is there any option that returns newly updated or created document with full object instead of count in mongoose bulkWrite() method?
const operations = [
{
updateOne: {
filter: { email: 'email.1@gmail.com' },
update: {
firstName: 'firstName.1',
lastName: 'lastName.1',
password: 'Password',
…

Manish Rathod
- 11
- 3
1
vote
1 answer
Getting request identifier in Mongoose 'pre' & 'post' hooks
I am using Mongoose (latest version), Type script (NestJS).
I am working on collecting some metrics about our queries using 'pre' & 'post' hooks to measure the query time (including the network latency).
I have added a 'pre' hook that should start a…

Roy Leibovitz
- 579
- 5
- 16
1
vote
1 answer
How to add new Fields to Mongoose Schema before save and update Query?
I want to add dynamic fields to Mongoose Schema every time before add/update record. Since, I have defined the fields into the separate JSON file and want the same JSON fields to be added dynamically every time to the Mongoose schema. Is this…

Satnam 363
- 19
- 1
1
vote
2 answers
Mongoose Paginate V2 with or operator
I need to create a query in mongoose paginate V2 whit or operator, suppose I have a collection "employees" like this:
[{
"firstName": "Jhon",
"lastName": "Doe",
"monthlyIncome": 50
},
{
"firstName": "Jhon",
"lastName": "Smith",
…

Pillo
- 347
- 1
- 4
- 15
1
vote
0 answers
mongoose or mongo node.js driver?
I am working on MERN Stack project right now and Got confuse to whether use mongo driver which was made for node.js or to use mongoose framework.
I cannot get the basic details , usage , and architecture of both of the framework. Please help me to…

anish gupta
- 15
- 3
1
vote
1 answer
Mongodb community - at rest data encryption in node js
I'm looking for a way to encrypt the entire DB and keep the ability to search for data although it's encrypted.
I have seen a lot of questions regarding encryption of at rest data in Mongo, but none of it got an answer that can help one complete a…

Avner Israel
- 176
- 1
- 15
1
vote
1 answer
Mongoose Pre and Post hook: stopping a query from execution
I am working on versioning changes for an application. I am making use of the mongoose pre-hook to alter the queries before processing according to the versioning requirements, I came across a situation where I need to do a separate query to check…

kgangadhar
- 4,886
- 5
- 36
- 54
1
vote
1 answer
How to import mongoose-long plugin with es6 way
I want to convert following import syntax into es6 import syntax
const mongoose = require('mongoose')
require('mongoose-long')(mongoose);
const {Types: {Long}} = mongoose;

hein soe htet
- 13
- 3
1
vote
2 answers
Query the fields in 3 different nested arrays in same document in Mongoose?
Below is my Schema design
const Schema1 = mongoose.Schema({
_id: false,
id: { type: mongoose.Schema.Types.ObjectId,
ref: 'UserinfoSchema'
},
name: { type: String , default: null },
from: { type: Date, default:…

code.mevn
- 155
- 1
- 2
- 10
1
vote
1 answer
Mongoose 5 suddenly errors "MongoError: unknown string alias for $type: 2dsphere"
I were using Mongoose 4.x and everything was fine. Soon I updated it to Mongoose 5.0.1, I started getting this error
/Users/me/ExampleCode/example-backend/example-backend-admin/example-backend-admin-places/node_modules/mongoose/lib/utils.js:417
…

Mohamed Heiba
- 1,813
- 4
- 38
- 67