Skip to main content
12 votes
Accepted

Twitter streamer that stores data in mongodb and emails errors

You can avoid almost all of your redundancy by writing a function that accepts the status code as parameter. I defined a collections.defaultdict dictionary for the ...
Graipher's user avatar
  • 41k
7 votes
Accepted

Mongoose: find() and count() query

Solution After reviewing many answers, I believe I have two options: Make two queries, like I am doing now, Use a pagination plugin for mongoose My decision was the second one and so I am now using ...
Flame_Phoenix's user avatar
7 votes

MongoDB Perl Wrapper

I'm the lead engineer for the MongoDB Perl driver with a couple of thoughts for you: you're using 'authenticate', which is for a very old version of the driver which is not recommended for use. In ...
xdg's user avatar
  • 171
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
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.4k
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
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
  • 3,961
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
  • 941
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.2k
3 votes

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

One of the biggest things you can do to clean up you code is to simply remove the unnecessary if-else blocks. In many cases you have a return inside the first conditional, which means there is no ...
Mike Brant's user avatar
  • 9,608
3 votes

Twitter streamer that stores data in mongodb and emails errors

There are several major violations in the code: DRY principle - the email_me_error* functions are almost the same except the error messages the scope and the ...
alecxe's user avatar
  • 17.3k
3 votes

RESTful APIs (Create, Read) with flask-restful

The MongoClient was designed to be instantiated once per app life cycle, so this is redundant. You should try to reuse ...
Artem's user avatar
  • 281
3 votes
Accepted

'join' MongodDB collections with a for loop

The nested loops perform books.length * favorites.length iterations (up to 4 million). Instead build a dictionary of id -> rating, so total iterations max is a sum ...
wOxxOm's user avatar
  • 1,952
3 votes

RSS to JSON for insertion into MongoDB

No, that's not a good design. Catching NullPointerException is almost never the correct thing to do. Effectively ignoring it is worse. You're hiding possible ...
Eric Stein's user avatar
  • 6,514
3 votes
Accepted

MongoDB CRUD operations for various types of data in Go

I am also starting out in go (although I used GAE's Datastore), and have spent some time thinking about this. I considered 3 options: 1 Code Generation I think code generation would be a solid way to ...
BJR's user avatar
  • 46
3 votes

MongoDB Perl Wrapper

Please check comments in the code, ...
mpapec's user avatar
  • 1,176
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
  • 941
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,287
3 votes
Accepted

connection to mongodb in golang

You say this is common in all handlers: ...
Elias Van Ootegem's user avatar
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
  • 55.7k
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

Basic commenting structure for commenting on objects

##################################################################### # Comment ########################################################### This sort of stuff is ...
Pimgd's user avatar
  • 22.3k
2 votes

Querying MongoDB for information on a collection of books

Use Promises. Promises will help with all the indentation, and make your code more clean and understandable in the future (believe me, you'll have no idea of what you were trying to do if you read ...
Daniel Bastos's user avatar
2 votes

RSS to JSON for insertion into MongoDB

If you were to keep the original method JSONObject::jsonBuilder as is, then you should document the fact that null values are an expected return type. Because null ...
flakes's user avatar
  • 1,925
2 votes
Accepted

Retrieve rich text from GridFS with Java

Since you are already on Java 7, you can use try-with-resources on your BufferedReader for safe and efficient handling of the ...
h.j.k.'s user avatar
  • 19.2k
2 votes

Avoiding nested callbacks when using MongooseJS

This is due to asynchronous JavaScript, and this is called Callback Hell. You can deal with it through some design patterns, the Zoltan's answer is a really good one (way better than mine). But I'll ...
Hugeen's user avatar
  • 303

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