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 ...
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 ...
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:...
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 ...
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-...
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 ...
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 ...
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 ...
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...
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 ...
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 ...
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 ...
4
votes
Accepted
MongoDB cache decorator
Personally I'd implement these changes:
1) Custom serialization protocol
...
3
votes
Accepted
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 ...
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:
...
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, ...
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:
...
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 <...
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 ...
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 ...
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 ...
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).
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
...
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'...
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 ...
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 ...
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 ...
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:
...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
mongodb × 184javascript × 74
node.js × 64
python × 47
mongoose × 28
performance × 17
express.js × 17
java × 14
go × 11
rest × 9
pymongo × 8
c++ × 7
c# × 6
beginner × 6
error-handling × 6
promise × 6
spring × 6
flask × 6
python-3.x × 5
ruby × 5
ruby-on-rails × 5
database × 5
scala × 5
object-oriented × 4
api × 4