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
1 answer

Mongoose keeps creating indexes for old fields that do not exist anymore

So I had a model User with username and password fields. Later I changed it to use email instead of username. A similar change was made on another model - I renamed username to name. Both fields used unique validation from mongoose-unique-validator.…
Simoroshka
  • 339
  • 1
  • 7
  • 18
0
votes
1 answer

MissingSchemaError while using mongoose-observer library

I have a typical Node.js, express, mongoDB and mongoose application. I'm trying to implement the mongoose-observer library to listen for changes on my mongodb. See site: https://www.npmjs.com/package/mongoose-observer When adding this code (almost…
Jan
  • 560
  • 6
  • 19
0
votes
1 answer

Mongoose Random Query issues

I'm trying to figure out why a mongoose query I'm writing always returns null. Not [] as usual but null. Here is the code: // Get random single opponent within 300 points of your team value in either direction app.get('/api/teams/getOpponent',…
Connor McGill
  • 259
  • 4
  • 17
0
votes
2 answers

Bad request in nodejs

I used passportjs and passport-local-mongoose for creating user signup. This is my code var express =require("express"), app =express(), bodyParser =require("body-parser"), passport =require("passport"), …
0
votes
1 answer

Mongoose operation field is 'find' when I do 'update', why?

I don't know if this is related to Mongoose itself or MongoDB driver. Here is the deal. I want to add created/updated fields to my schemas. I know that Mongoose can do it out of the box, but I need to use Unix Timestamp instead of date object. To…
0
votes
1 answer

Incorrect document revision number found in post update middleware

I have a Mongoose plugin which I use to increment the documents revision number (__v), as well as create revision itself. The plugin covers the Documents Doc.save() middleware function, as well as the Query update and findOneAndUpdate middleware…
Justin
  • 1,959
  • 5
  • 22
  • 40
0
votes
1 answer

How to find mongoose-thumbnail "uploads" and "u" directories

I'm working with mongoose-thumbnail to get an thumbnail of a image I upload, I done it exactly as in the github mongoose-thumbnail example and it works very well, below is my code var mongoose = require('mongoose'); var thumbnailPluginLib =…
shamila
  • 1,280
  • 6
  • 20
  • 45
0
votes
1 answer

Mongoose FindOne not working directly after create

I am setting up seed data with the goal of only creating a record if it does not already exist. I am using the https://www.npmjs.com/package/mongoose-find-one-or-create plugin to only create records if they do not exist and it is not working. I have…
David Cruwys
  • 6,262
  • 12
  • 45
  • 91
0
votes
2 answers

Other nosql database than mongodb with mongoose?

I would like to use another platform than mongodb with mongoose. I used mongoose in my school project, and my school ask me to have a multiple database project. Any idea ? I don't want to duplicate my code.. Thanks
Johnny
  • 2,989
  • 4
  • 17
  • 28
0
votes
0 answers

How I can update a field only if it undefined? and if defined not update, but update the other fields

I have the following document: { "_id": 55d91b345ad7478c0c1a5c51, "name": "pasa la plaza", "testCases": [ { "stateTestCase": "deberia jalar yo creo", "_id": "55d91b5a5ad7478c0c1a5c52" } …
0
votes
1 answer

Update a document based on a query depending on other collection

Is there a possibility in Mongodb to update a document, based on a query for 'count' of docs in other collection? I'm looking for options to make it an atomic operation. To be more specific, the following is how the two collections are…
Vsoma
  • 595
  • 1
  • 5
  • 17
0
votes
0 answers

Is mongoose capable of having pluggable backends other than MongoDB, like plain, old JSON files on the filesystem as a datastore?

We have a tool that is normally used on a server (in the cloud, behind the firewall, etc). It uses Mongoose with MongoDB. We now need to use our tool as a standalone app on a laptop and want to reuse the code that uses Mongoose. We are considering…
Matthew Adams
  • 2,059
  • 2
  • 21
  • 31
0
votes
3 answers

Is it possible to use `required: true` validation by clause?

I have the following schema: var Schema = new mongoose.Schema({}); Schema.add({ type: { type: String , enum: ['one', 'two', 'three'] } }); Schema.add({ title: { type: String //, required: true ned set by…
Erik
  • 14,060
  • 49
  • 132
  • 218
0
votes
1 answer

How to write a custom populate for mongoose ODM?

Mongoose has a populate function to deref object by id. model.find(...).populate('a_ref_field') I want to create a function to deference automatically by data in the field which specify collection and id e.g., foo:…
0
votes
1 answer

Populating ref to the parent using Mongoose and displaying complete parent after authentication with passportjs

I have the following schema for user and sp. sp is short for service provider. Service provider is a user, it has a reference to user. I am trying to signup and singin using PassportJS module of NodeJS. I have been able to signup an sp and I could…
skip
  • 12,193
  • 32
  • 113
  • 153