Most voted "mongoose" questions
Mongoose is a Mongodb object modeling tool, or ODM (Object Document Mapper), written in Javascript and designed to work in an asynchronous environment.
Learn more…189 questions
Sort by count of
-
1
votes0
answers98
viewsKeystonejs with remote Mongo
Good night! I’m starting to study Keystonejs versão 0.3.17. Following the "Getting Started" of the official website, in the prerequisites nodejs and the mongodb, but I want to use that cloud service…
-
1
votes0
answers44
viewsChanges have no effect when I change Schema, using mongodb and nodejs
Every time I make a change in my Schema I have to restart my server. I’m using the nodemon, but it doesn’t always update, someone has been through it? module.exports = function(app){ var Schema =…
-
1
votes0
answers61
viewsPost Error - Payload (Node.js)
Today when I went to perform the post of a larger base 64 is returning it from my server. When uploading a smaller image it sends smoothly, I tried using some solutions limiting the server to 50mb…
-
1
votes1
answer624
viewsRelationship between documents - Mongodb
I have the following model: A schema called suspects, which holds information of suspicious persons. And 3 other so-called alerts, criminal actions and risk events. These 3 other schemas, must have…
-
1
votes1
answer67
viewsDifficulties to find() in the schema/model Mongoose with req.params.
As the title says, I’m having trouble making a find() customized in Node model/schema, which links with Mongoose. My file correspondencia.js (model) below: var mongoose = require('mongoose'); var…
-
1
votes1
answer123
viewsProblem registering objects nested in Mongodb with Mongoose
I have the following collection: // SUSPEITOS - INICIO // const suspeitosSchema = new mongoose.Schema({ nome: { type: String }, sexo: { type: String }, corPele: { type: String }, altura: { type:…
-
1
votes2
answers462
viewsUndefined when accessing class attributes in Nodejs
Good afternoon, you guys, was developing an api with Node and Mongo using express and Mongoose and tried to implement the Pattern Repository, but when accessing the attributes of a class returns a…
-
1
votes1
answer706
viewsThe `useMongoClient` option is no longer necessary in Mongoose 5.x, Please remove it
I tried to connect to the bank using these settings; 'use strict' var mongoose = require('mongoose'); mongoose.Promise = global.Promise; mongoose.connect('mongodb://127.0.0.1:27017/ep', {…
-
1
votes1
answer293
viewsAdd document subdocuments - Mongoose
Good evening! I have the following document: { "_id" : ObjectId("5b21a4332a5e3333cc64a12f"), "nome" : "João", "sobrenome" : "Barbosa", "cpf" : "12345678910", "senha" : "Fabet@1010", "viagem" : [ {…
-
1
votes1
answer554
viewsHow to create a field that references a sub-array of a Collection in Mongoose?
Imagining the following structure(Merely illustrative example): Collection: Schools [ { "_id":"abc123", "nomeEscola":"escola1", "turmas":{ "_id":"ccc333", "nomeTurma":"Turma1" } }, { "_id":"abc122",…
-
1
votes1
answer460
viewsnodejs + Mongoose how do for one query need another?
I have two tables they have a link id being table A(Initial) tableB(dependencies) however there may be dependencies. I’d like you to just return in the dependency sequence. function Deps(dt) {…
-
1
votes2
answers97
viewsUse updatemany in Mongoose in a request
I’m trying to make a update/Insert with the Mongoosis when finalizing a request. This request returns to me, for example: let obj = [ {nome: aaa,idade: 10}, {nome: bbb,idade: 11}, {nome: ccc,idade:…
-
1
votes1
answer828
viewsHow to Save and Recover Images in Base64 using Mongoose in a Nodejs Service?
I need to save and recover an image in Base64 through a REST service developed with Nodejs. For this, I have created the following schema on Mongo: const userSettingsSchema = new Schema( { 'avatar':…
-
1
votes2
answers381
viewsMongoose pre method, returns this as empty object
I have the following model, where when registering the user in mongodb , I want him to encrypt the password using bcryptjs, using the Mongoose method UserSchema.pre('save'... const bcrypt =…
-
1
votes1
answer202
viewsEvery time I start a server Mongoose makes an unnecessary connection to the database
Good evening, everyone! I’m starting in the area and as a first goal I decided to create a simple e-commerce, only every time I start my server, it runs a connection to the database unnecessarily, I…
-
1
votes1
answer218
viewsError picking up input from a <form> with Mongoose/nodejs
Hello, I recently started learning Node.js and I’m using Mongoose to integrate with db 'mongodb', and in this application I’m trying to take data of 2 and insert this data into the database, I made…
-
1
votes1
answer383
viewsMongoose is updating wrong object in mongodb
I have a problem saving the data in mongodb. Context I have an express api that listens to requests to save the data to the mongodb an application sends. This data is related to APP page views,…
-
1
votes0
answers25
viewsCreate subquery in Mongoose
Which brings the following table ________________________________________ id | descricao | ip | id_parent | 1 | Teste | 14 | 0 | 2 | Outro | 15 | 1 | 3 | Meter | 16 | 1 | 4 | Tra | 17 | 2 | I have…
-
1
votes0
answers559
viewsHow to use "import" properly in a Node.js application with typescript
Good afternoon. I am writing a Rest API using node.js and typescript, but I’m having trouble using the import in some parts of the programme. for example in my server.ts I have: const connectDB =…
-
1
votes0
answers32
viewsMongoose Always returning an Empty array Nodejs
I’m using only find() on my server to Try to Retrieve data from Mongodb with Mongoose, but it retriveis this "{}", and on the console "Array(0) []" js router. const Teams = require('./models/map');…
-
1
votes1
answer173
viewsSearch username in a Query of the Mongoose-paginate
I am trying to do a user search field and for that I will receive via query param a variable search, which will contain the string search (in this case, the name (or part of a name) of one or more…
-
1
votes1
answer52
viewsTreat req.files as null
Good night. I’m starting now with studies in web development and would like to know how to treat the following:What I developed was a blog, and in the area of creating posts, there is a form for you…
-
1
votes1
answer134
viewsPopulate() Ngoose only returns Objectid
I imagine it’s something very simple to solve but I’m already several hours trying to solve and I get nowhere. I’m developing a blog as a way of study but I’m having problems using the populate() of…
-
0
votes0
answers79
viewserror installing Mongoose in win server 2008 R2
The error below appears when installing Mongoose on the op. server 2008r2 system All applications are installed correctly. but the database does not seem to compile. c:\program…
-
0
votes1
answer598
viewsAdd json event url in fullcalendar
I’m using fullcalendar, nodejs and Mongoose. I’ve already managed to generate the json file. But when passing the path in the js of fullcalendar, I cannot recover the events. I created a json test…
-
0
votes1
answer1375
viewsLast entry
I need to know how to get the last record stored in Mongo. I’m doing a search, comparing two IDS, need only return the last record. I have the following variables:: client.name client.cpf…
-
0
votes2
answers327
viewsMongodb problem in listing data with php
var mongoose = require('mongoose'); var db = mongoose.connection; // db connect db.on('error', console.error); db.once('open', function() { console.log('Conectado ao MongoDB.') });…
-
0
votes0
answers422
viewsUpdating a list of documents in mongodb
I’m trying to update a list of objects similar to this: var lista = [ { _id: 57ea29361b297553c99d702f, nome: 'Meu nome', __v: 0 }, { _id: 57ea29371b297553c99d7031, nome: 'Meu outro nome', __v: 0 } ]…
-
0
votes1
answer417
viewsUpdate specific element in a Mongoose array
How to update the following record: "_id": "56dd4489800f800000000000", "registro": "2014-09-07T09:06:17.214Z", "stars": 0, "observacoes": [ { "texto": "", "dataResposta": "", "idUsuario":…
-
0
votes1
answer464
viewsFind in two Customers using Aggregation
I need to perform a find on two Collections in mongodb using Aggregation and place the results in a single array. I’m trying to do it this way, but it doesn’t work. I have Visiting and Opportunities…
-
0
votes1
answer9
viewsWhen I store the ID it disappears with some numbers
I was making an app and in it I needed to store the id which is pretty great type this was my id 173782035419103232 but when arriving at the database it modifies to 173782035419103230 as I can do…
-
0
votes1
answer470
viewsError in Mongoose findOne
I’m getting Error: Invalid argument to findOne(): 'texto pesquisado' when executing the findOne mongoose: const User = mongoose.model('users', mySchema); const query - 'texto pesquisado';…
-
0
votes1
answer286
viewsHow to make a findOneAndUpdate in an array within another array with Mongoose
I am beginner in Mongoose, I would like to make an amendment (findOneAndUpdate) in the second array address in the city field, I tried everything I knew and I thank nothing to everyone who can help.…
-
0
votes1
answer28
viewsMongodb on air at AWS
I need a help, I did not find anything practical and exact in google, I have a backend with Node and using Mongoose, and I can run site quietly, because in CMD I run the command 'mongod', and my…
-
0
votes0
answers98
viewsUsing two connections with Mongodb using Mongoose with references to distinct collections
I have two Mongodb databases that I connect using Mongoose on Nodejs, one with an X collection that references the ID of another Y collection that is in another Mongodb database on another server. I…
-
0
votes1
answer143
viewsDoubt about the structure of the Nodejs + Mongo app in Digital Ocean
Guys by indications I started using 1 machine at Digital Ocean in place at UOL Host. As I don’t have much experience with the server setup part, I’m in doubt and hope someone will help me: Setting:…
-
0
votes1
answer88
viewsRank system using Mongodb
I’m having a hard time using the aggregate of Mongodb. I need to pick up 5 users who collected more items. username: 'gg_Max', items: [ { encrypt: "WccmGN3k6vpbfcdVuWmhTT", results: { collected: […
-
0
votes1
answer311
viewsMongoose Nodejs: error when connecting with Mongodb
I am trying to connect to the Mongodb database but the following error occurs: My code: when I run the mongod server command: If anyone can help me find a solution, I’d be grateful…
-
0
votes0
answers24
viewsEnum and default does not work?
Greetings dev’s, I have the following schema in my app: const customerModel = new Schema({ ... roles: [{ type: String, required: true, enum: ['user', 'admin'], default: 'user' }] }) However, when I…
-
0
votes1
answer1654
viewsWhat is the function of the populate method in Mongoose?
I am doubtful to understand the functionality of the populate method in Mongoose
-
0
votes1
answer133
viewsReference in the mongodb
Well, guys, I know there’s no such thing as a relationship, but I need to know how to do something related. I have two collections a call, Extinguisher and the other Historical, I want an extinct…
-
0
votes1
answer110
viewsfind no req.body using populate
Controller async index(req, res) { const avali = await Avaliacao.find(req.body) .populate('Time').exec((time, err) => { console.log(`Para retorna tudo ${time}`) }) return res.send(avali) }, Model…
-
0
votes1
answer970
viewsHow to update to Node.js and Mongoose
{ "_id": "58fe27e0e340671c9859c995", "__v": 0, "form": [ { "_id": "58fe2b1de437791cd02b9a8c", "sections": [ { "_id": "58fe2b1de437791cd02b9a8d", "input": { "_type": "radio" } } ] }, { "_id":…
-
0
votes1
answer230
viewsSave() method of Mongoose not saved
I have the following problem: When calling the Mongoose save method it seems to be doing nothing. The save code is as follows:: var newProjects = new projectModel({ "teste":"teste" });…
-
0
votes1
answer750
viewsTypeerror: Uri.indexof is not a Function
I am making a Crawler using Node.js and mongodb to save the information in the bank and I have the following code: var request = require('request'); var cheerio = require('cheerio'); var save =…
-
0
votes1
answer83
viewsChange document after post-save middleware in Mongoose
I’m working with the Mongoose.js And I’m going to need, after I save the document to the database, to be able to change an attribute of that document. From what I understood in the Mongoose…
-
0
votes0
answers36
viewsConnect to Mongodb with Token
My current connection file is this: const mongoose = require('mongoose') mongoose.connect('connect string url', { useNewUrlParser: true }) mongoose.Promise = global.Promise module.exports = mongoose…
-
0
votes1
answer260
viewsProblem with Success message after registration of 2 inputs in the bank!
Hello, I have a problem in my code, after registering 2 inputs should appear a message of success in uam green div, but only appears the green div and the message no, already revised the code…
-
0
votes1
answer166
viewsI am unable to edit in CRUD - Nodejs + Express + Mongodb
next: I literally started working with Nodejs + Express + Mongodb today and as an exercise I started with the famous CRUD (Create, Read, Update, Delete). I managed to do almost everything except the…
-
0
votes1
answer93
viewsMongooose Middleware to encrypt password in Schema
I’m having a hard time putting a Middleware in my Mongoose schema. I put it as save and am getting the error that it is not a function when I call it. See below both codes: schema.pre('save',…