MongoDB + Node.js: one collection per request or one static collection?

MongoDB + Node.js: one collection per request or one static collection?

I am using the 'mongodb' NPM module in small web server.

I am using the 'mongodb' NPM module in small web server.

I'm wondering whether I should always call db.collection('') on every request that hits the server, or should I rather init a (singleton) collection after I established the db connection, and use the same collection for all requests?

Especially since I have the collection at hand during initialization, to set a unique index, it is pretty tempting to just keep this collection reference and re-use it in all http request handlers.

Could I run into awkward concurrency issues, say, if multiple requests at nearly the same time operate on exactly the same collection instance?

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

How to Use Express.js, Node.js and MongoDB.js

In this post, I will show you how to use Express.js, Node.js and MongoDB.js. We will be creating a very simple Node application, that will allow users to input data that they want to store in a MongoDB database. It will also show all items that have been entered into the database.

Build a REST API using Node.js, Express.js, Mongoose.js and MongoDB

Node.js, Express.js, Mongoose.js, and MongoDB is a great combination for building easy and fast REST API. You will see how fast that combination than other existing frameworks because of Node.js is a packaged compilation of Google’s V8 JavaScript engine and it works on non-blocking and event-driven I/O. Express.js is a Javascript web server that has a complete function of web development including REST API.

Node.js, ExpressJs, MongoDB and Vue.js (MEVN Stack) Application Tutorial

In this tutorial, you'll learn how to integrate Vue.js with Node.js backend (using Express framework) and MongoDB and how to build application with Node.js, ExpressJs, MongoDB and Vue.js