Questions tagged as 'mongoose'

1
answer

Sum of values Nodejs + Mongoose

I need to sum the values stored in a variable in the database. I have a form and I want to know the total value generated in a variable. Then I did the following: _.each(cliente.data, function (data) { fo...
asked by 01.09.2015 / 14:45
1
answer

The 'useMongoClient' error is no longer necessary in mongoose 5.x, please remove it

I tried connecting 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', { useMongoClient: true }) .then(() => {...
asked by 16.05.2018 / 13:56
1
answer

Add subdocuments to document - mongoose

Good evening! I have the following document: { "_id" : ObjectId("5b21a4332a5e3333cc64a12f"), "nome" : "João", "sobrenome" : "Barbosa", "cpf" : "12345678910", "senha" : "Fabet@1010", "viagem" : [ {...
asked by 14.06.2018 / 01:41
1
answer

export json file

I'm using nodejs, mongoose. No controllers at the end I give res.json(clientes); and in my route I create: app.get('/clientesjson/:id', isLoggedIn, cliente.clientesjson); I need to access my Json information by ID. In the cu...
asked by 16.06.2015 / 22:28
1
answer

Problem registering nested objects 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: String }, peso: { type: String },...
asked by 09.11.2017 / 19:40
1
answer

Compare multiple arrays

I have two arrays, which are: data [ 0{ nome: a numero: 2 } 1{ nome: b numero: 3 } 2{ nome: b numero: 3 } 3{ nome: b numero: 8 } ] dataNota[ 0{ nf:...
asked by 03.05.2016 / 22:05
2
answers

Sum of number of records per year and month

I need to generate a Json file that will feed a graphic. I need to load the following information. I have a form that receives date (dd / mm / yyyy). My chart shows the number of visits per year x month. I make the following conference in...
asked by 01.09.2015 / 19:43
1
answer

How do I create a field that references a sub-array of a collection in mongoose?

Imagining the following structure (illustrative example only): Collection: Schools [ { "_id":"abc123", "nomeEscola":"escola1", "turmas":{ "_id":"ccc333", "nomeTurma":"Turma1" } }, {...
asked by 13.09.2018 / 14:18
1
answer

How to relate two models with mongoose?

I have two models in my bd user.js var mongoose = require('mongoose'); var Schema = mongoose.Schema; var bcrypt = require('bcrypt'); // User Model var UserSchema = new Schema({ name: { type: String, unique: tru...
asked by 29.01.2018 / 19:14
1
answer

How to get DB value for a variable?

I have the following question: I have a database in mongoDB, I do the search of the data by NodeJS it returns me all right, however I would like to play this search value for a variable, to make a comparison. Type I search the date in DB and wou...
asked by 04.12.2016 / 13:22