Questions tagged [mongoose-plugins]

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.

79 questions
0
votes
2 answers

MongooseError: Model.findOne() no longer accepts a callback && userSchema.plugin(autoIncrement.plugin, 'user');

import mongoose from "mongoose"; import autoIncrement from "mongoose-auto-increment"; const userSchema = mongoose.Schema({ name: String, username: String, email: String, phone:…
0
votes
0 answers

(mongoose-sequnce)(mongoose) + Hapijs Adding auto increment in schema field

I want to add an auto-increment field in the MongoDB schema for Interview.round.count field i.e. whenever I will Update the interview field it will automatically increase the Count value with +1 //Here is My Schema Field const mongoose =…
0
votes
0 answers

mongoose query middleware getFilter not working

I want to apply throwing errors for all "one" operations where the document is missing. I'm following the advice from one of mongoose collaborators: mongoose.plugin((schema) => { schema.post(/One/, function (doc, next) { if (doc) return…
Shining Love Star
  • 5,734
  • 5
  • 39
  • 49
0
votes
0 answers

UnitTesting with TypeScript and Jest (Mongoose plugin problems)

I am trying to make ts-jest working but I am getting an error from not really related to the method functionality. I've got a class ProductService with a demo method `` import { ProductModel, ProductPriceModel, ProductTypes, …
user16373392
0
votes
1 answer

Mongoose global plugins not working (ES6)

I'm running into an issue with mongoose.plugin() and none of global plugin changes seem to be affecting the schemas. Other than importing, I've tried directly writing the plugin in the same index.js file, and removing pointer functions. The global…
0
votes
1 answer

mongoose-mpath module is creating the document but not assigned to it's parent

const {category, parent} = newCategory; const newCat = new Category({ _id: new mongoose.Types.ObjectId(), name: category, parent: parent }).save((err, res) => { if(err) {…
0
votes
0 answers

How does mongoose (Builder pattern) chained methods work under the hood

The question is more on the mongoose implementation of chained methods than actually mongo queries. I am working n a plugin implementation for which I need to provide custom methods like populate, count, etc. shown below. a.find({ b: 'thing'…
kgangadhar
  • 4,886
  • 5
  • 36
  • 54
0
votes
0 answers

Mongoose find return an empty array but return values when i set a variable to the model

why is the first query not working I am using mongoose i want to e able to check for errors during query that why I want to use the first instance import Work from './WorkModel.js' const response = await Work.findOne({ user: userId}).exec((err,…
0
votes
1 answer

Retrieve Mongoose Query Queue Time Metrics

In order to optimize the connection pool size, I thought it would make sense to graph query queue times. Is it possible to retrieve this metric from Mongoose?
0
votes
1 answer

How to set mongoose plugin to a schema after creating NestFactory

I'm using nest, I need to call another service to get a key before setting a mongoose plugin, I tried to init the mongoose plugin in main.ts, but it doesn't work, below is what I did test.schema.ts import { Document } from 'mongoose'; …
troy
  • 2,145
  • 2
  • 23
  • 31
0
votes
1 answer

mongoose-paginate module is not supporting query operators

I just realised that mongoose-paginate IS NOT supporting Comparison Query Operators https://docs.mongodb.com/manual/reference/operator/query-comparison/ Example: (created_on: Date) Post.paginate({ created_on: { gte: new…
parse
  • 1,706
  • 17
  • 27
0
votes
0 answers

_.each throws error after npm update

Everything was running fine, before I run 'npm update' to push my code with latest libraries. Now I am getting error: { message: 'Method Map.prototype.has called on incompatible receiver #', stack: 'TypeError: Method Map.prototype.has called on…
0
votes
0 answers

populate nested array of nested ref

The structure of the project is structure The main file is index.js that is located in the main directory. This one has 'use strict' var mongoose = require('mongoose'); var app = require('./app'); var port = process.env.port ||…
0
votes
0 answers

populate embed array mongoose 5.0. Nested ref

This is the first model. It's located in the folder called models/user.js 'use strict' var mongoose = require('mongoose'); var Schema = mongoose.Schema; var UserSchema = Schema({ publications: [{ description: String, …
0
votes
0 answers

nested ref to populate mongoose 5.0 nodejs

I have two models. The first one is UserSchema and the second one is CategorySchema var UserSchema = Schema({ firstName: { type: String, required: true }, secondName: String, lastName: { type: String, …