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
15
votes
4 answers

How do you remove a model from mongoose?

I don't mean remove a document or documents. I mean remove the model entirely so that mongoose is no longer aware of it. After declaring a model I can't figure out how to make mongoose forget that model so that it could be…
CatDadCode
  • 58,507
  • 61
  • 212
  • 318
10
votes
6 answers

Mongoose Plugins nestjs

How can I implement the mongoose plugin using nestjs? import * as mongoose from 'mongoose'; import uniqueValidator from 'mongoose-unique-validator'; import mongoosePaginate from 'mongoose-paginate'; import mongoose_delete from…
8
votes
1 answer

Mongoose advanced custom schema object type

I couldn't find any example of an advanced custom schema type involving custom objects (or value-objects) in Mongoose >=4.4. Imagine that I want to use a custom type like: function Polygon(c) { this.bounds = [ /* some data */ ]; this.npoints =…
Dario
  • 3,905
  • 2
  • 13
  • 27
6
votes
1 answer

Error calling 'paginate' after import schema within plugin

I have a problem using paginate in my controller after add plugin to my schema, my code is written in TypeScript 2.1, i have installed @types/mongoose-paginate in devdependencies. [ts] severity: 'Error' message: 'Property 'paginate' does not exist…
6
votes
1 answer

mongoose-paginate sorting by referenced document

I would like to sort my Group-Model by the name of the departure_country with mongoose-paginate and NodeJS. My Group-Schema: var GroupSchema = new Schema({ name: String, flight_date: Date, .... departure_country:…
molerat
  • 946
  • 4
  • 15
  • 43
6
votes
2 answers

In mongoose pre middleware, how do i access the update query?

I am trying to use the new unstable version of mongoose >4.0.0 to validate update queries. say that i want to update a schema using the following query schema.update({_id:'blah'},{a:'blah'},function(err){ //do your thing }) so lets say i have the…
JasonY
  • 752
  • 10
  • 24
6
votes
3 answers

Error: text search not enabled:- in mongodb

I get the following error :- [Error: text search not enabled] I am running the folliowing function which is essentially a mongoose-mongodb operation. var textSearch = require('mongoose-text-search'); exports.dbTextSearch = function () { …
Sangram Singh
  • 7,161
  • 15
  • 50
  • 79
5
votes
1 answer

how to override function of mongoose plugin?

I have a plugin in mongoose and for each schema i am doing the following var user = new Schema({}); user.plugin(myplugin); user.statics.createCustomDoc = function() { ..... } The problem is the createCustomDoc method is also defined in…
codeofnode
  • 18,169
  • 29
  • 85
  • 142
4
votes
0 answers

Adding a global Mongoose Plugin in Nestjs after Mongoose 5.10.5 with built-in type declarations

Types are added to Mongoose 5.10.5 and it seems they are different from @types/mongoose. Then my code is not running anymore: import MongooseDeletePlugin from 'mongoose-delete'; ... @Module({ imports: [ MongooseModule.forRoot(MONGO_URI, { …
rostamiani
  • 2,859
  • 7
  • 38
  • 74
4
votes
3 answers

Error: mongoose-auto-increment has not been initialized

I am creating a mongoose schema as follows : var adminSchema = new…
kumarD
  • 574
  • 2
  • 9
  • 23
4
votes
2 answers

Use mongoose hook to retry saving on duplicate key error

I would like to use a mongoose middleware hook to re-try saving a document in case the initial save failed with a duplicate key error. The use case is as follows: My model uses slugs for identification which are automatically generated. E.g. item,…
qqilihq
  • 10,794
  • 7
  • 48
  • 89
4
votes
1 answer

Accessing Express.js request context in Mongoose models

I am developing a REST API with my colleagues using Express.js and Mongoose. For some of the Mongoose Model methods and statics we need the Express.js Request object as an added context information source, like the authenticated user currently doing…
m_vdbeek
  • 3,704
  • 7
  • 46
  • 77
3
votes
0 answers

I can't use mongoose-aggregate-paginate-v2 and mongoose-paginate-v2 in the same project

in a part of the project I need to use mongoose-paginate-v2 and it works perfect the problem occurs when I try to implement mongoose-aggregate-paginate-v2 in another data model because when I install it it warns me that in the implementation of…
CARLV
  • 71
  • 1
  • 4
2
votes
2 answers

Is exexPopulate() method is deprecated from the mongoose new version?

main() const main = async () =>{ const task = await Task.findById('614ac31e103d9c5329d38686') await task.populate('owner').execPopulate() console.log(task.owner) } execPopulate() is not a function
2
votes
3 answers

How to use `mongoose-delete` plugin with NestJs and typescript?

I'm using Mongoose in NestJs library and want to use mongoose-delete plugin for all of my schemas. But I don't know how to use it with nestJS And Typescript. First i installed both mongoose-delete and @Types/mongoose-delete libraries but there is no…
rostamiani
  • 2,859
  • 7
  • 38
  • 74
1
2 3 4 5 6