Questions tagged as 'express'

1
answer

Find in two collections using aggregation

I need to perform a find on two collections in mongodb using aggregation and put the results into a single array. I'm trying to do this, but it does not work. I have the collection Visits and Opportunities and want to summarize the amount...
asked by 16.03.2016 / 15:31
1
answer

Error connecting MongoDB

I'm having trouble connecting MongoDB. Follow the code: var express= require('express'); var app= express(); var bodyParser= require('body-parser'); var db_string= 'mongodb://localhost/teste' var mongoose= require('mongoose'); var db= m...
asked by 28.04.2015 / 10:52
1
answer

"TypeError: Crud.Select_products is not a function", I am getting this error when trying to access a method of an exported class, in NodeJS

Server.js file var express = require('express'); var Crud = require('./database/Crud'); var app = express(); app.get('/api/home', function(req, res){ let results = Crud.Select_products(); res.send(results); }); app.listen(5000, (...
asked by 02.01.2019 / 20:48
0
answers

How to change the connection to the database using Sequelize + MySql + Express depending on the parameter sent in the request?

For example, when you receive a parameter in the request equal to db1, in the precise controller that uses the db1 connection string When you start the NodeJS server, the config.json configuration with the connection data is already loaded....
asked by 19.12.2018 / 18:17
0
answers

Doubt with subdomain express vhost

How can I have vhost with extension? for example HowItried:app.use(vhost('api.*/portfolio',portfolioRouter));app.use(vhost('api.**/portfolio',portfolioRouter));Butitdidnotwork.Iwonderifthisispossible,andifthat'show?TheAPIisworkingcorrectly.I...
asked by 03.12.2018 / 18:28
0
answers

pass array as parameter to query query, express

Well, I would like to basically pass an array through the url to the red.params of express.router, I tried to do it in some ways: router.get('/:[ids]?', function (req, res, next) { portfolioModel.deleteArray(req.params.array, function...
asked by 10.12.2018 / 18:28
0
answers

About the app.delete () command

I'm reading a book called "Mean_ Full stack JavaScript for web applications with MongoDB, Express, Angular and Node." No "cap 5.7 - page 120" shows this: // identificador iguais, muda apenas o verbo< app.get('/contatos/:id', controlle...
asked by 15.11.2018 / 18:29
0
answers

Routing in files in separate directories express

Well I'm having a problem, I'm trying to render a html page, but I do not want to use any 'view engine' for this, but I can not make my routes that are in a separate directory rendered in my app file. js that are in the root know how I can do th...
asked by 08.11.2018 / 21:14
0
answers

Can I create a function that inserts the routes registered in the APP for SEED [SEQUELIZE-CLI]?

I have a function that takes all the routes registered in the express and registers these routes in the bank using Sequelize. app._router.stack.forEach(function(r){ // console.log(r.route.path) if (r.route && r....
asked by 15.10.2018 / 22:46
1
answer

Problems with routers node + express

I have a sequence of methods (get, post, put, delete), however the put method is wrong and I do not know how to solve it. This is the snippet of code: router.route('/') .get((req, res) => res.status(200).send('Lista de Produtos'))...
asked by 26.09.2018 / 22:13