Sorting by inner object field and its performance

I'm confused that it's hard to make case insensitive sorting work. So I decided to just add second field in addition to main text field in lower case. I'm using C# driver and in my object model I have something like SortableString which contains orig...
more »

2017-06-15 08:06 (1) Answers

Storing sensitive data in mongodb/node

I am working on a project which requires my web app to collect sensitive information from users (e.g. photo of driver's license.) This is done via a file upload on Angular and I was planning on storing the images as a binary array in MongoDB. I was a...
more »

2017-06-13 16:06 (1) Answers

mongodb: only update document if is not updated

I have this function. Allow take a service only is not taken: is taken only if the available param is true. function takeService(req, res) { var serviceId = req.params.id; var driverId = req.body.driverId; Service.findById(serviceId, (err, se...
more »

2017-05-25 17:05 (1) Answers

MongoDB sort by relevance (mix $and and $or)

with 2 documents like : { "name": "hello", "family": 1 }, { "name": "world", "family": 1, "category": 2 } and a query like : doc.find({$or: [{family: 1}, {category: 2}]}) how can i have results sorted with the one matching t...
more »

2017-05-23 21:05 (1) Answers

Node.js & Mongoose sorting problems

I'm trying to sort two articles by descending date. Can't undersand, why it doesn't sort it right. My dates: 2016-05-17T09:59:00.000Z, 2017-05-03T10:00:00.000Z My sorting mechanism: return this.model.find(parameters.filter).sort({createdAt: -1}).li...
more »

2017-05-21 13:05 (0) Answers

Using Mongo Cache as a replacement for redis

Currently, i am writing data into redis which is reduced to mongo every 2 minutes. I am wondering if i can use Mongo Cache instead of redis here. This will save the cost of 2 dbs in production.Also,the mongodb page says : The WiredTiger cache st...
more »

2017-05-19 07:05 (0) Answers

Pass large array to node child process

I have complex CPU intensive work I want to do on a large array. Ideally, I'd like to pass this to the child process. var spawn = require('child_process').spawn; // dataAsNumbers is a large 2D array var child = spawn(process.execPath, ['/child_pro...
more »

2017-05-18 18:05 (6) Answers

Removing documents not having @ in mongodb

I am created a mongodb and in the I am filling my client email addresses and there related accounts. But I have found that some values listed as email are not email at all. See the below example. { "_id" : ObjectId("591d9cf30ef9acde11d7af6b"...
more »

2017-05-18 16:05 (1) Answers

Mongo @Query vulnerable to SQL/No-SQL Injection?

I'm developing a Spring MVC web based app and I'm using MongoDB with MongoRepository interface for persistence. In some of my queries to the DB, I don't use the MongoRepository (or CrudRepository) reflection method naming like findByEmail(string emal...
more »

2017-05-16 09:05 (0) Answers

MongoDB document validation fail

Trying to test the validation of the document below: db.createCollection("Users", { validator: { $and: [ { Uid: { $type: "string", $exists: true } }, { "Doc.Name": { $type: "stri...
more »

2017-05-13 22:05 (0) Answers

Security on MLab Access on React Frontend

I would like to render highcharts on my react frontend. The data is coming from my mlab mongodb. There is native mongodb drivers available, I dont know though, whether I can expose my password and user on the react frontend. Is there any security iss...
more »

2017-05-12 20:05 (1) Answers

delete item by date in mongodb using php

I need to delete a mongodb element using php based on the date of the element When i fetch the Date of the element without any formatting or conversion i get this as an output 0.52400000 I dont know which format this is but by using date...
more »

2017-05-12 12:05 (1) Answers

Query MongoDb records from 5 days ago using '_id'

I've read online that '_id' holds a timestamp on when it was created and you are able to query it depending on a date. This is what I've I tried so far, but not having any luck. var d = new Date(); d.setDate(d.getDate() - 5); collection.find( { }, ...
more »

2017-05-07 08:05 (1) Answers

Will this create any security exploit?

I've a mongodb collection "users" in which i want to add a new field "wallet_amount" when user add money in their wallet. Right now at the time of user registration, i'm trying to insert a document like this db.users.insert( { email: "test@test.com"...
more »

2017-05-05 18:05 (1) Answers

Mongoose sort, ascending and $exists

I wonder if there is a way in mongoose that I can sort a query on a collection in ascending order on a certain field where that field also gets sorted on $exist. I mean the following query sorts like I want but puts the documents with no track.nextRu...
more »

2017-05-04 16:05 (0) Answers

MongoDB Validator on Array of Objects

Lets say I've got an Events collection that has documents that look like this: { name: "myevent", invitees: [ { name: "mike", bff_level: 3 }, { name: "michelle", bff_level: 2 } ] } I want to enforce t...
more »

2017-05-02 01:05 (0) Answers