DEV Community

Cover image for Redux Toolkit and Mongoose
Anik Barua Turjoy
Anik Barua Turjoy

Posted on

Redux Toolkit and Mongoose

I have learned new technology Redux tool kit and mongoose.

Mongoose:

Mongoose module is one of the most powerful external modules of NodeJS. Mongoose is a MongoDB Object database Modelling that used to translate the code and its representation from MongoDB to the Node.js server
Advantages of Mongoose module:
Collection validation of the MongoDB database can be done easily.
Predefined Structure can be implemented on the collection.
Constraints can be applied to documents of collections using Mongoose.
Mongoose module built on the top of MongoDB driver and provides easily abstraction of the query and define a query.
Additionally, it implements validation and other neat features in order to make sure your schema is consistent when inserting/updating/finding documents from collections. It also creates Model abstraction which makes it easier to work with, so it looks like you are working with just objects rather than pure data.
Mongoose is an incredibly popular and well-done library in the NPM universe. It is used extensively by many excellent programmers based upon its Model-Schema structure.
So I have practiced with Mongoose to keep my required validation strong.

Redux Tool Kit:

When working on a Frontend project that has to make use of a state container, the go-to library for most engineers is Redux. This is a very good library for managing your states. It is described as SOPE which stands for Simple, Opinionated, Powerful and Effective. While working with the standard redux library, there are many issues we encounter which include
Redux requires additional installation of other libraries to make it more effective, an example is the reselect library, which is a selector library for redux.

Redux requires a lot of boilerplate code, which most developers don’t like doing, where you find yourself writing action creators over and over again for example.
Complicated configuration setup.

Redux Toolkit package was built in mind to so solve these cases by abstracting the setup process and also handling redux common use cases, to best illustrate this, I would be comparing a use case using the standard redux library with using the redux toolkit library. It also provides the automatic support for Redux Dev-tools Extension and for immer.js library which is a great tool to deal with immutable objects. You can also use the various predefined functions of Redux Toolkit which not only speeds up the process but also saves time.
Dependencies that comes along with Redux Toolkit:
Immer, redux, redux-thunk, reselect

I am still learning and practicing those technology, because I believe practice makes a man perfect.

Top comments (0)