Questions tagged [mongodb]

MongoDB is a scalable, high-performance, open source, document-oriented database. It supports a large number of languages and application development platforms.

Filter by
Sorted by
Tagged with
15 votes
1 answer
293 views

Making an efficient and healthy db call for a real-time browser game

I'm doing a calculation for a real-time browser game, where users can invest some of their balances to the site. I need to update their invest's based on ...
Lazy's user avatar
  • 163
15 votes
2 answers
5k views

Test mongoose model

I have mongoose model: ...
Naor's user avatar
  • 515
15 votes
2 answers
827 views

Builder pattern for users in document database

I'm attempting to make a builder pattern that makes sense and is practical for storing user data in a flexible way in a document database. The DB I chose is MongoDB, and I'm using its Java API ...
Phrancis's user avatar
  • 20.4k
12 votes
1 answer
19k views

Seeding MongoDB using Mongoose models

I'm using mongoose to seed a mongodb database based on my mongoose models. I'm particular interested in improving the seed code. I have two models, an article and a category. The relationship between ...
Gerard Downes's user avatar
11 votes
3 answers
330 views

Conditionally set attributes in MongoDB based on form fields

I have code which gets data from a POST request (request.form dict), compares with corresponding attribute in object ...
Mirzhan Irkegulov's user avatar
11 votes
2 answers
4k views

NodeJS broker between MongoDB and RabbitMQ

I wrote a small program that aims to take some data from the MongoDB database and put them in the RabbitMQ queue. I tried to use only promise style but I am a beginner in JavaScript. Could you please ...
Julio's user avatar
  • 113
9 votes
1 answer
38k views

Mongoose: find() and count() query

Background I have a query in Mongoose that finds a set of objects, and then returns these said objects together with the total number of them: ...
Flame_Phoenix's user avatar
8 votes
1 answer
74 views

Retrieving StackExchange sites and tags

I have setup agenda tasks to periodically retrieve and possibly insert new SE sites and tags in my MongoDB database. Some things that bother me in particular: Lots of code duplication No string ...
Jeroen Vannevel's user avatar
8 votes
1 answer
3k views

One-to-many relationship with Python objects

I have built Python objects to simulate a one-to-many relationship and then store the object in a MongoDB instance. I am using lots of composition to achieve what I want. The code works perfectly fine ...
ajknzhol's user avatar
  • 461
7 votes
2 answers
1k views

Twitter streamer that stores data in mongodb and emails errors

Here is a Python script that streams Twitter either with a keyword or within a bounded geographic area. Errors are emailed to my Gmail and the tweets are stored locally in MongoDB. Please let me know ...
walk_for_life's user avatar
7 votes
3 answers
116 views

Pulling Docker Machine IP

I am working with MongoDB through Docker, and I have a terrible bash command to pull the Docker Machine IP so I can sanely connect locally. ...
Sienna's user avatar
  • 453
7 votes
2 answers
127 views

Recursive download articles and dump to MongoDB

This is simple code that recursively downloads articles from the public WordPress API: ...
toy's user avatar
  • 831
7 votes
2 answers
3k views

Insert 271 million records from text file to mongodb

I have 271 million records, line by line in a text file that I need to add to MongoDB, and I'm using Python and Pymongo in order to do this. I first split the single file containing the 271 million ...
Diandro's user avatar
  • 71
6 votes
2 answers
151 views

MongoDB Perl Wrapper

I'm trying to create a custom "mongodb perl wrapper". I created the following perl module, which local on my machine runs. My questions to the community are: Would you create the module different? Do ...
Patrick85's user avatar
  • 491
6 votes
2 answers
2k views

Simple telephone address book

I am new to Java programming, and to help me learn, I created a simple telephone address book. The code runs as expected, but I would be interested to here from more advanced programmers if they ...
user2369812's user avatar
6 votes
1 answer
1k views

Updating state with React

I am creating a blog using React, MongoDB, Express and Node. I have three components: App, List, and Item. The item is a blog post; the list is a list of the blog posts, and the app includes a place ...
anon's user avatar
  • 183
6 votes
1 answer
69 views

creating accounts with passportJs

I'm currently building an application using Passport and bcrypt for user authentication. I've created the registration part. Is there anything I could improve on? I'm still getting the hang of writing ...
imnewhere's user avatar
6 votes
1 answer
2k views

Listening from Mongodb always and triggering

I am using classes for the first time. In this program I want the object to run infinitely so that any change in the MongoDB will trigger the function and do the necessary processing. I am little ...
Nikhil Parmar's user avatar
5 votes
3 answers
19k views

Get all followers and friends of a Twitter user

I'm trying to find my bug or any potential bottleneck that cause my program to be really slow. The script is to get all the followers and friends and save that in MongoDB. ...
toy's user avatar
  • 831
5 votes
3 answers
229 views

Verifying requirements before deleting a user-parent-student-school relationship

I am new to node, after I finished my APIs I realized that all of them are a mess, and are a callback hell, this forced me to learn about promises, now it was all good until I faced an API that has ...
motchezz's user avatar
5 votes
2 answers
895 views

RESTful APIs (Create, Read) with flask-restful

I wrote this simple API to be able to send logs from the client to MongoDB. Even though this works and fits my need, I would like to point out some concerns that I have regarding the following: Is ...
ellaRT's user avatar
  • 243
5 votes
1 answer
185 views

Express.js blogging application

I have put together a blogging application with Express, EJS and MongoDB. There is a public, front-end part and a dashboard. In index.js I have: ...
Razvan Zamfir's user avatar
5 votes
1 answer
1k views

Image duplicate finder

I have a bunch of exact-duplicate pictures that I've acquired over the years. I'd like to create a list of all them so I can eventually delete some. My idea was simple: dump the hash and location of ...
David says Reinstate Monica's user avatar
5 votes
1 answer
4k views

Node js single mongodb connection

I want my entire node application to use one single mongodb connection, at least that's what I think is better. I wrote this little script and want some feedback on it. Especially if what I'm doing ...
user3425765's user avatar
5 votes
1 answer
1k views

E-commerce product price tracker

I building a very simple price tracker web app. I am using MongoDB with pymongo. The user will enter the URL of the product he wishes to track and the desired amount, when the price goes below this ...
avi's user avatar
  • 973
5 votes
1 answer
195 views

Resource closing in a promise chain

This is some code that fetches a result from a database. It connects, makes a query, processes the query, then has to close the DB (under all possible code paths) and return the result. It seems ...
jfriend00's user avatar
  • 3,938
5 votes
1 answer
2k views

MongoDB inventory system

I am trying to develop a simple inventory system that takes JSON data gathered from a Powershell script, inputs the data into a MongoDB, and displays the info in an interesting manner for the user. It ...
Jeff's user avatar
  • 459
4 votes
3 answers
188 views

Find events associated with users on a certain date in MongoDB

I have this script which works perfectly but I experienced some delays because of these 2 for loops [i][j]. Is there any way to ...
Nodegeek's user avatar
  • 151
4 votes
2 answers
233 views

MongoDB connection manager

I wrote a class for some MongoDB operations. So far I'm self-taught and mostly I follow the style from already existing code at my workplace (a startup). We don't have a code-review culture, so I'm ...
Vaibhav yB Shah's user avatar
4 votes
2 answers
726 views

Spring Boot API - Avoiding Concurrency issues

I'm still in the process of learning Java / spring and I think I'm getting better. Now at this point I'm able to build a rest api BUT I'm at a lost at how to ensure I've no concurrency issues . I've ...
MetaCoder's user avatar
  • 153
4 votes
1 answer
58 views

Get data and send mail script

I wrote a script using Python that gets data from several sources (news sites, Twitter, Yahoo), puts it into a dict and then formats it as a string to be sent through email. I wonder if there is ...
Alex T's user avatar
  • 133
4 votes
2 answers
2k views

Modularize this node.js express server code for routes and session handlers?

I have express node.js server code using Passport. It receives a user to authenticate it and ...
diegoaguilar's user avatar
4 votes
1 answer
2k views

Optimizing async joins for mongodb (mongoose) using async.js

I'm building a media viewer web app for a kiosk in node that uses data in mongo. To render the viewer, it gathers together all the Asset objects (representing video files), each of which belong to a ...
Luc's user avatar
  • 41
4 votes
1 answer
5k views

"Clean Architecture" design pattern with Node.JS and MongoDB

After some time poorly designing my web applications' backends (mixing database calls with the controller, etc.), I have decided to try the "Clean Architecture" approach. In this example I have a ...
kibe's user avatar
  • 277
4 votes
1 answer
226 views

Commands Object creation using chained Builder pattern

Context As many of you may know I have a library that allows C++ objects to be converted into JSON/YAML/BSON automatically with a single declaration (see previous code reviews). I am now (trying) ...
Martin York's user avatar
  • 94.6k
4 votes
1 answer
1k views

Node.js chat client

This is a chat using Node.js, socket.io and MongoDB for storage. I'd appreciate any feedback on what can be improved. I understand that this allows for non-unique usernames to be used, and it's ...
Alex Garrett's user avatar
4 votes
1 answer
199 views

Tabulating a report

I have a method for generating a report in Python. I want to organize the section about the date into a separate method so I can repeat the report for different dates. What's the best way to ...
DBWeinstein's user avatar
4 votes
2 answers
178 views

Querying MongoDB for information on a collection of books

I have this huge chunk of code. Is there any better to write this code, or am I too paranoid that I check every MongoDB query for error? The logic is here: ...
Tim's user avatar
  • 337
4 votes
2 answers
3k views

Node.js script may have memory leak

I use this node.js script to migrate MongoDB collection to a schema to another. It does work if the collection is <20k documents, but slows down to a crawl and sometime throw a FATAL ERROR: JS ...
DrakaSAN's user avatar
  • 210
4 votes
1 answer
278 views

User-like MongoDB implementation

This is my first implementation of MongoDB, much much more to come. This sheds light on some things like how I've structured my collection. I hope to gain feedback and insight from the community on ...
ThomasReggi's user avatar
4 votes
1 answer
669 views

Enhancing search using Fuzzy Logic in NodeJS

Brief Description: In my NodeJS Application, I have a model called User. User.js ...
Sudarshana Dayananda's user avatar
4 votes
1 answer
1k views

Ping multiple sites via Python

Here is a simple script that I am using to ping 50 sites at a time and check if they are up or not. If not, save the down time with error in MongoDB. ...
Mak's user avatar
  • 291
4 votes
1 answer
333 views

MongoDB - Find records in one collection that match string in 2nd collection

I have a MongoDB collection of product IDs/unique products attributes and a second collection of codes that relate to attributes common for products whose IDs are prefixed with those codes. For ...
getglad's user avatar
  • 229
4 votes
0 answers
397 views

MongoDB BulkWrite - create or update a sub document within an array

I have a series of Events (roughly 10-20 events that will be dynamically created per month): Event Model: ...
Matt Carlotta's user avatar
4 votes
0 answers
226 views

Get nearest driver from 2.5 millions of data using mongodb

I have created 2.5 millions drivers dummy data, in this case lets say the drivers are moving around in the city. The driver's document look like this : ...
Gujarat Santana's user avatar
4 votes
0 answers
2k views

Mongoose schema for products and social media posts

Here is my current schema: Brand: ...
NoobSter's user avatar
  • 193
3 votes
1 answer
97 views

Customer MapReduce implementation

I would love a second opinion / another pair of eyes on this. ...
ThomasReggi's user avatar
3 votes
2 answers
82 views

Simple automation executing platform in Python

I'm building a platform like Rundeck/AWX but for server reliability testing. People could log into a web interface upload scripts, run them on servers and get statistics on them ( failure / success). ...
amos-baron's user avatar
3 votes
1 answer
810 views

Bash script to deploy a mongodb cluster on local machine

I recently wrote a small script to deploy a mongodb cluster on a single machine. The cluster is composed of : 3 configurations server that holds the same informations (they are replicas ) 2 shard ...
felix's user avatar
  • 588
3 votes
1 answer
53 views

'join' MongodDB collections with a for loop

This is a very simplified version of my query. Is it acceptable to join the two collections for the client with the use of for loops? There could be up to 2,000 books, which also means there could be ...
NoobSter's user avatar
  • 193