Questions tagged [mongojs]

MongoJS is a Node.js package to access MongoDB.

References:

306 questions
1
vote
0 answers

How to get only one field in mongodb in dynamic inner levels?

I am working on a web application and cannot get myself over my issue. On the website there are categories. Main categories and each category has own subCategories and the subCategories could have also subCategories. All of them are building up by…
vitticeps
  • 71
  • 1
  • 6
1
vote
1 answer

Is it possible to globally set projection options for all queries in MongoDB?

I don't usually want or need the "_id" field to be returned in my queries. So, for each query, I have to set: { $projection: "_id": 0 } Is it possible to set this value globally so that any query executed will not include the "_id" field?
Fernando Vega
  • 525
  • 4
  • 13
1
vote
1 answer

Compile two different mongodb entries

I am just starting with javascript / express / mongodb. As a little starting project I want to do a simple task manager. The todos should be divided by prios. So every entry has it's flag "high", "mid" or "low". However, I can't manage to show the…
daniel_e
  • 257
  • 1
  • 11
1
vote
2 answers

GET from 2 different MongoDB collections using MongoJS

I am using MongoJS to fetch data from mongo db in the following way: app.js: var db = mongojs('db', ['events']); And then: app.get('/', function(req, res){ db.events.find(function(err,docs){ res.render('index', { title:…
MrG
  • 33
  • 9
1
vote
1 answer

Getting error while connect to mongoDB in MongoLab using Node.js

I am getting the below error while connect to mongoDB present in MongoLab using node.js. Your environment has been set up for using Node.js 6.9.1 (x64) and npm. C:\Users\User>cd C:\xampp\htdocs\fgd C:\xampp\htdocs\fgd>node server Server is running…
satya
  • 3,508
  • 11
  • 50
  • 130
1
vote
0 answers

Get request not returning single item from collection with id param

I have this code that should return a single item from a tasks collection, stored in a database hosted on mLab. router.get("/task/:id", function(req, res, next) { //callback function upon get db.tasks.findOne({_id: mongojs.ObjectId(req.params._id)},…
Leth
  • 1,033
  • 3
  • 15
  • 40
1
vote
2 answers

How to get the array value and in structurized using Mongoose?

I am using MeanStack AngularJS. I stored the values into MongoDB like this: Data format "RoleName" : "Verify", "IsActive" : true, "UIList" : { "UiName": "One", "View" : false, "Edit" : false }, { …
jose
  • 1,044
  • 1
  • 12
  • 35
1
vote
1 answer

MongoDB: Insert multiple documents into collection with unique index even if some violate the index

I am trying to insert an array of documents into a MongoDB collection. The collection has a unique index on one of the fields. I am inserting all the documents at once as such: const mongojs = require('mongojs'); const db =…
etayluz
  • 15,920
  • 23
  • 106
  • 151
1
vote
1 answer

Mongo failed to connect to server on first connect

I know that's a way discussed issue, and have gone through almost every topic I found on SO and google in general about it, but still no resolution! The problem At random points in time, the following error occurs MongoError: failed to connect to…
Orestis Samaras
  • 153
  • 1
  • 9
1
vote
2 answers

How to insert particular values into Mongodb using Angularjs MEAN STACK

I store input values into mongodb using scope name. I have a 3 fields when I click add all values are in object so I directly send the scope name into server and store it. I would like to store only 2nd textbox values and remaining values should be…
jose
  • 1,044
  • 1
  • 12
  • 35
1
vote
1 answer

Nodejs - Checking for empty object from MongoDB and parsing it

Im trying to implement a simple login mechanism from NodeJS(using ExpressJS) and MongoDB. Im using MongoJS for the DB connectivity. I am using the $and: to see if the fields match inside the collection. function authenticate(req,res){ username =…
CoderSenju
  • 39
  • 8
1
vote
2 answers

$https delete is not working in nodejs and mongodb ,not able to delete

id i m getting in the controller but its nt coming in the server,when i am clicking on delete i am getting the id in console. its showing error "possibly unhandled rejection" and error 404 this is my server:- var express=require('express'); var…
1
vote
1 answer

Why the callback never gets called when reading all data from MongoDB?

I recently updated my machine to the Node.js version 7.5.0 (if I remember well, I was using version 4 before). One of the applications which worked before doesn't work any longer. The problem could be reproduced like that: var connectionString =…
Arseni Mourzenko
  • 50,338
  • 35
  • 112
  • 199
1
vote
1 answer

mongodb continueOnError not suppressing duplicate key errors

I am trying to keep a collection with unique keys. Data to be inserted comes from various distributed places (although individual documents are immutable), and could possibly contain duplicates. I was hoping to simply insert records and suppress…
Andy Hume
  • 40,474
  • 10
  • 47
  • 58
1
vote
0 answers

is there any way to import third party JS into mongoJS...?

I am looking for a function to convert UTC timestamp to another timezone timestamp. It needs two parameters, utcTimestamp(1464891132) & timezoneString("Asia/Kolkata") function convertToTimeZone(utcTimestamp, timezoneString) { //do some…
piyushmandovra
  • 4,219
  • 3
  • 19
  • 30