The mongod.cfg file for configuring the mongod process

So with mongodb there is the mongod binary that is the actually process daemon or service that handles requests for data in a database. It other words it is what always runs in the background on the computer that is hosting the database that is being used in a project that makes use of mongodb. Well one thing that might come of interest with this is how to configure mongodb with settings like the port to listen on, and if authentication should be enabled or not. Well one way is to give some of these options to the binary via the command line when staring it, but maybe a better way is to park these settings in a configuration file of sorts, thats where the mongod.cfg file comes into play. In this post I will be giving a quick overview of

Read More

Making a mongodb connection module.

The process of connecting to a mongodb database can some times be a little complicated. When connecting locally the hostname and port might not be of much interest, if the mongod service is running on the default port, and there are no issues with using localhost as the hostname. However the situation can become very different when it comes to deployment, where not only does the hostname and port matter, but there is often a username and password that need to be specified as well in order to connect to and use a database. As such there seems to be a need to create, and maintain a module, that can be used to quickly connect depending on the environment. In many cases this module may need to be custom trailered depending on the environment, or at the very least bust be able to accept arguments, or look for environment variables.

Read More

The mongodb connection string

The mongodb connection string is one of the first things I have become aware of when getting started with using mongodb as a database solution. Understanding this string is critical not just for the sake of using mongodb locally, but also when it comes to deployment as well as the content of the string will typically differ between those two environments. In this post I will be writing about the mongodb connection string, and relevant must know topics surrounding this when it comes to things like authentication.

Read More

The lodash sort by method

So I have come to find that I like the lodash _.sortBy method more so than the native Array.prototype.sort method for a few various reasons. I do still use it of course when it comes to working with a project where lodash is not part of the stack, it is just that the method works in a way that I find more natural when it comes to the return value and arguments used for the function that is passed to the sort by method. I will be elaborating what I mean by that in this post.

The _.sortBy method is another option compared to the _.find method also, the _.find method can be used to find just one item in a collection, while the _.sortBy method can be used to sort the whole collection, I can then take just the first element, or the top three. So lets take a look at some examples of sorting with lodash, and native javaScript as well.

Read More