Questions tagged as 'mongoose'

1
answer

Search for an element in a MongoDB database using Nodejs

Alright, here I have a code where I have my Express server, the connection to the database and apparently everything works fine. const express = require('express'); const path = require('path'); const cookieParser = require('cookie-parser'); c...
asked by 22.12.2018 / 19:53
1
answer

Mongodb error: $ in needs an array

I am modifying the delete function in a crud. Originally taskID was a single ID to be deleted; while in my program it is an array of multiple IDs. I do not know what the line of code with mongodb or mongoose would be like to eliminate all the ta...
asked by 04.01.2019 / 05:08
0
answers

Mocha / Chai: Unable to do login testing

I am writing tests for a login service. The test must pass if the login is correct. Before each test my test database is cleaned. That's why I first created a user and then I try to login. The expected behavior is to receive status 200 when the...
asked by 14.12.2018 / 12:33
0
answers

I can not update mongodb from Mongose

I try to add data to my Array by mongose but nothing happens, in the DB continuous same, I can not change it. Model Dao DB    No matter how many times you run, it does not change, it is no...
asked by 10.12.2018 / 05:38
1
answer

Create objects with references Node Js and MoongoDB

Hello, I have the following data models in mongo db var mongoose = require("mongoose"); var accountSchema = new mongoose.Schema({ name: String }); module.exports = mongoose.model("Account",accountSchema); A second model var mongoose...
asked by 21.11.2018 / 01:47
0
answers

insert same value denied

good day, I have a query where I should change the value of a boolean for its denied value, for it would take care of the positional $ operator but what I do not find in the documentation is how to deny it, I leave the query that I am using:...
asked by 20.11.2018 / 16:40
1
answer

Pass mongoDB query to Mongoose

I need to pass the following MongoDb query to Mongoose: db.propiedads.find({ _id:ObjectId("5bb18cc42a8f2d23d8dfcd65"), "planes.plan":ObjectId("5bb565f6382cf30364b182e5") }) Currently this query is working in the mongo console. now I ad...
asked by 11.10.2018 / 04:12
1
answer

Method $ push does not work (MongoDB, Mongoose)

How about. I'm having a problem I have an array in mongodb, which is supposed to store objects, but I can not add them. Student.update(mongoose.Types.ObjectId("5bc25777d9dded06a4635430"),{$push:{sanctions:{reason:'test'}}}); It is assumed t...
asked by 15.10.2018 / 17:35
0
answers

How to use a model in another model in mongoose | Node.js with Mongoose

I'm doing a task application with node.js, express and mongoDB, the fact is that I'm trying to use my data from my model called User in my model called Task, my schema User has a field called tasks which is an array where all the tasks go, then...
asked by 08.10.2018 / 17:52
0
answers

update with mongoose when saving with save () does not trigger the process

I try it in all possible ways: Modelo.findById(req.params.id).then(datos =>{ datos.name="value" datos.save(); }).catch(err=>{ res.json(err); }) Here I do it with a return :...
asked by 28.09.2018 / 09:51