Skip to main content
5 votes

Insert 271 million records from text file to mongodb

First, you need to consider that adding 271 million records is going to be long, there's no changing that. You should also consider your processing power. You could have the best code in the world, if ...
IEatBagels's user avatar
  • 12.7k
5 votes
Accepted

Get data and send mail script

Now isn't now You call now at the top of the program. First of all, it's never used, so it should be deleted. Even if it were used, this call should be moved next ...
Reinderien's user avatar
  • 71.1k
5 votes
Accepted

Find events associated with users on a certain date in MongoDB

I think the main cause of your delays is not a nested for but rather the fact that you extract all data from your MongoDB collection into memory. What you can do is:...
Bohdan Stupak's user avatar
5 votes
Accepted

MongoDB connection manager

Highlevel review Dunder methods are reserved by the Python language and reserves the right to make any unofficial dunders not work in a future Python version. Don't name things ...
user226435's user avatar
5 votes
Accepted

c++ Mongo Interface

Remove support for big-endian systems Unless you want your code to run natively on an IBM z/Architecture mainframe, there are basically no computers used anymore that run (let alone support) big-...
G. Sliepen's user avatar
  • 69.2k
4 votes

Retrieve a city list for a country and state

Utilize the query object, this type of querying is more suitable there than as params. Use object destructuring. Dry your code, see how we're mapping over ...
Ehab Khaireldin's user avatar
4 votes
Accepted

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

Your code looks very structured and nicely written, but to my understanding, your solution is not "clean architecture" (CA) as described by uncle bob. Your solution is an MVC solution. In clean ...
Adi Cohen's user avatar
4 votes
Accepted

Spring Boot API - Avoiding Concurrency issues

Welcome to Code Review, because Spring demands to the user the responsibility of avoiding concurrency issues better always check if the possibility of concurrent issues exists. About your ...
dariosicily's user avatar
  • 4,086
4 votes
Accepted

Change interface depending on if statement

Since the types seem to be identical except for the JSON tags, you could use either models.UserModel or models.UserModelOmitempty...
muru's user avatar
  • 973
4 votes

Pulling images from a MongoDb database

Some quick remarks: Your code uses inconsistent capitalization, which often does not follow Microsoft's guidelines. Don't needlessly abbreviate: why use "repo" in ...
BCdotWEB's user avatar
  • 11.4k
4 votes

Connecting MongoDB using Motor in FastAPI

@classmethod In connect() and close(), it's weird to see you assigning these: Database._client Database._db Prefer the ...
J_H's user avatar
  • 42.1k
4 votes
Accepted

Mongo Queries In C++

Don't use $ in identifiers // I know using $ is an extension. Then you also know it's not standard C++, and it might stop ...
G. Sliepen's user avatar
  • 69.2k
4 votes
Accepted

MongoDB cache decorator

Personally I'd implement these changes: 1) Custom serialization protocol ...
Adversing's user avatar
  • 336
3 votes
Accepted

connection to mongodb in golang

You say this is common in all handlers: ...
Elias Van Ootegem's user avatar
3 votes

Spring, Kafka and Mongo how to create a RestController

From your question and code, I understand that you are trying to consume events from Kafka topic, persist in MongoDB. Also, exposing api's to retrieve data from Mongo DB and send in response. If ...
Surendra S's user avatar
3 votes

Java MongoDB client as a singleton

Simple answer: No. Unless if your application only ever runs on 1 thread. The easiest way to lazy initialise a singleton thread safe would be with a holder pattern. Example from wikipedia: ...
Imus's user avatar
  • 4,387
3 votes
Accepted

Bash script to deploy a mongodb cluster on local machine

To begin with, I agree with Jesse_b that command substitution should use $(). There's no reason to use backticks in a bash script that uses arrays (that's to say, ...
muru's user avatar
  • 973
3 votes
Accepted

creating accounts with passportJs

The use of arrow functions looks okay to me. One advantage to using them is that they can be simplified to a single line but one might hold the opinion that is less readable. For example: ...
Sᴀᴍ Onᴇᴌᴀ's user avatar
3 votes
Accepted

Commands Object creation using chained Builder pattern

Is it more efficient for the user of this API? It looks nice for a single insert operation, but what if I need to insert many things, all with the same options? I would not want to have to repeat the <...
G. Sliepen's user avatar
  • 69.2k
3 votes

Connecting MongoDB using Motor in FastAPI

I am quite unfamiliar with Mongodb and best practices so I won't delve too much in the specifics. To enhance what @J_H has written: A close method is typically run ...
Kate's user avatar
  • 8,293
3 votes
Accepted

C++ Mongo Interface : Version-2 Op_Msg

Usage I'm not sure if you really meant there to be two functions sendMessage() and getMessage(). If not, then next time don't ...
G. Sliepen's user avatar
  • 69.2k
2 votes
Accepted

Finding unreferenced documents

There is a better way, but this assume that you have an index on vid field (for example, {"vid": 1} ). If you don't, you can create one using ...
felix's user avatar
  • 608
2 votes

Python app-level document/record locking (eg. for MongoDB)

The above code will fail with multiple worker nodes (or processes). To achieve atomic find-and-update, mongodb provides native solution (findOneAndUpdate, findAndModify, updateOne, updateMany).
Nan Wang's user avatar
2 votes

Updating multiple collections

I really think your code is having at least two issues. The first one is something that may confuse your service consumers a lot. The second one is probably a bug. Careful With Status Codes ...
Igor Soloydenko's user avatar
2 votes

Generating Report Data in CSV format for various cases

Ok, no problem with your POJO classes, fields/getters/setters - its basic so its fine. But controller - controller should not have 20 things happening in it. I don't see the import section, so can'...
Sergii Nevydanchuk's user avatar
2 votes
Accepted

How can I get this two functions into one

The functions are almost identical for the first 3 lines of code. Applying DRY (don't repeat yourself) principles you would call the first function in your second function instead of rewriting the ...
Markus Dresch's user avatar
2 votes

Retrieve a city list for a country and state

From a short review, Make sure that your database has an index: https://docs.mongodb.com/manual/indexes/ For the 404, since most countries have more than 1 city, I would return "Cities not found", I ...
konijn's user avatar
  • 34.3k
2 votes
Accepted

Speed up Python Script to populate MongoDB

Just looking at wordPop since that's where you say the most time is being taken: I think your validity check is broken. There's an ...
scnerd's user avatar
  • 2,090
2 votes

Insert 271 million records from text file to mongodb

In order to make the comment by @IEatBagels made in their answer more explicit, you can just do this: ...
Graipher's user avatar
  • 41.7k
2 votes

Find events associated with users on a certain date in MongoDB

I don't fully understand what you are trying to achieve with this code, and you haven't really described it very well. I'm reasonably sure, though, that all this code should be completely eliminated ...
200_success's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible