Questions tagged as 'mongoose'

2
answers

Check if it exists before saving in moongodb and nodejs

I need to store an array in my MondoDB database. This I do without problems with the following code: My array of objects: [ { name: '1', type: 'float', value: 89.05, timestamp: 1535440000 }, { name: '10', type: 'float', value: 19.67, time...
asked by 05.09.2018 / 13:12
2
answers

Match two models in mongodb

I am in trouble to be able to relate two models in mongodb. I was looking for some forums the methods populate() , aggregate() . But they do not work for that matter (I think). I have model A {title : 'hola'} , model B...
asked by 10.08.2017 / 16:12
1
answer

Delete productId with Nodejs & Mongodb

Good! I am developing a mini API RESTFul with Node.js and Mongodb . The question is this, I am developing 4 basic functions for my API that would be GET, POST, UPDATE, DELETE . I'm having an error when performing...
asked by 25.04.2017 / 17:32
1
answer

Problem with a NodeJS and MongoDB connection with Mongoose

I am trying to create a connection between mongodb and nodejs, my code is as follows: const express = require('express'); const bodyParser = require('body-parser'); const pug = require('pug'); var app = express(); var mongoose = require('mongo...
asked by 12.06.2017 / 07:09
1
answer

How to read the video file that I have saved in my mongodb database

I'm trying to save a collection inside mongodb (Lesson) where among other data this collection has a video: Lesson Model 'use strict' var mongoose = require('mongoose'); var Schema = mongoose.Schema; var LessonSchema = Schema({ tit...
asked by 26.11.2018 / 21:20
1
answer

How can I do a find to search on an ObjectID in mongoose?

For example I have two models in mongoose: var Persona = { nombre: "Luis", carros:{ type: Schema.ObjectId, ref:'Carro' }, apellidos:"Colx Redex" } var Carro = { modelo:"FX-200", velocidad:"300km/h", marca:"Nissan" }...
asked by 08.09.2018 / 22:15
0
answers

Sort query output in mongoose (find) by two fields

I can not sort the result of a query in mongoose and I do not know if an aggregation function is necessary to achieve that order. I have a column called _id and another column called comment_id (which contains the main _id to reference). This...
asked by 29.08.2018 / 15:53
0
answers

Subqueries in mongoose

I have a problem when making subqueries in mongoose, I have two collections one place and another material , the place collection has an array of materials ids added by a user . Now what I'm trying to do is to be able to update a plac...
asked by 16.08.2018 / 21:02
0
answers

Mongoose Populate 2 arrays

I have a collection of products and another on the replacement of stock of the product. What I'm looking for is that when you get the products, all the product's stock dates appear, something like this: { "ok": true, "producto": { "rep...
asked by 06.04.2018 / 00:34
1
answer

Duplicate call to 'open' using mongoose

Good, starting at node.js and mongodb I'm first with a problem that I do not know if it is such. Having the server.js files as simple as 'use strict'; var http = require('http'); var express = require('express'); var bodyParser = require('b...
asked by 17.10.2017 / 14:29