Questions tagged as 'mongodb'

1
answer

Doubt in MongoDB modeling

As I studied, when modeling an application using MongoDB you should always think about the application. Thinking of a system that has a Promotion and Gender, where a promotion has a Genre, I saw that it will be necessary a screen to register the...
asked by 23.05.2017 / 03:24
1
answer

How to add item in API [closed]

I'm doing a basic forum just for testing, I'm using mongo and postman to add some things to test. But now, I want from the page, I send such data. Use http://localhost:3000/topico/cadastrar to add items. Follow the codes...
asked by 07.08.2016 / 03:11
1
answer

In MongoDB, how to search for documents by the size of an Array

I have a collection of documents that are nodes of a graph, where each node has its list of adjacencies: { '_id': ObjectId('547ce6f4ffaba82f360fc525'), 'adj': ['no_2'], 'nome': 'no_1' } { '_id': ObjectId('547ce6f4ffaba82f360fc526'), 'adj': ['n...
asked by 02.12.2014 / 01:19
1
answer

Using model.find () with LIKE in mongoose

I have a function here to search MongoDB using mongoose, but I would like it to find Brazil when I search for bra, Bra, Sil, sil, etc. I looked at the documentation and followed the example but it did not work, it does not return anything. Here...
asked by 03.01.2019 / 19:40
1
answer

mongo-hacker error installing

I'm trying to install mongo-hacker on my pc, but getting an error I can not figure out. Here's what the terminal returns: gabriel@Constantine:~$ npm install -g mongo-hacker npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/mongo-hacke...
asked by 18.09.2014 / 01:46
1
answer

MissingSchemaError: Schema has not been registered for model "Product"

Well, I'm following a tutorial on Node.js and MongoDB and I'm trying to create a product, so I create a list of attributes that the objects will have, until everything is ok. Following the video in question, I happen to the same error occurred...
asked by 06.12.2018 / 23:12
2
answers

Mongoose findone does not return values

Well, I have a problem here that I do not know what to try, I'm using express + mongoose. My model let mongoose = require('mongoose'); let users = mongoose.Schema({}, {strict: true}); module.exports = mongoose.model('users', users); My c...
asked by 18.11.2018 / 20:11
1
answer

NODE.JS - Error: Route.get () requires a callback function but got a [object Undefined]

In my roters I create: var express = require('express'); var router = express.Router(); var service = require('./../services/users'); router.get('/login', service.login); router.get('/register', service.register); router.get('/edit/:id',...
asked by 03.11.2018 / 17:07
1
answer

MongoDB - Use .distinct on 2 properties of a document

I have the following dataset in my database: { "_id": 1, "dept": "A", "item": { "format": "circle", "color": "red" }} { "_id": 2, "dept": "A", "item": { "format": "circle", "color": "blue" }} { "_id": 3, "dept": "B", "item": { "format": "rect"...
asked by 30.10.2018 / 19:46
1
answer

consider all fields when grouping in mongodb

I have the following array: [ { “user”: “USER1”, “last”: “USER1” }, { “user”: “USER1”, “last”: “USER2” }, { “user”: “USER2”, “last”: “USER1” }, { “user”: “USER2”, “last”: “USER2” }, { “user...
asked by 10.09.2018 / 16:44