MERN Stack Flashcards
(40 cards)
What is MongoDB?
MongoDB is a NoSQL database that stores data in a flexible, JSON-like format called BSON.
What are the key features of MongoDB?
Key features include scalability, flexible schema, high performance, indexing, replication, and support for sharding.
What is a document in MongoDB?
A document is a single record in MongoDB, stored as a BSON object similar to a JSON object.
What is a collection in MongoDB?
A collection is a group of MongoDB documents, analogous to a table in relational databases but with a dynamic schema.
What is the difference between MongoDB and a relational database?
MongoDB is a NoSQL database with a flexible schema and document-based storage, while relational databases use fixed schemas and tables with rows and columns.
What is an index in MongoDB?
An index in MongoDB is a special structure that improves the speed of data retrieval operations on a collection.
What is replication in MongoDB?
Replication is the process of synchronizing data across multiple servers to ensure high availability and redundancy.
What is recording in MongoDB?
Recording seems to be a typo; it likely refers to ‘sharding’ or ‘replication.’ Assuming replication: it syncs data across servers for reliability.
How does the aggregation framework work in MongoDB?
The aggregation framework processes data through a pipeline of stages (e.g., filter, group, sort) to transform and analyze data.
How do you perform a backup and restore in MongoDB?
Use mongodump to create a backup and mongorestore to restore data from the backup.
What is Express.js?
Express.js is a minimal and flexible Node.js web application framework that simplifies building APIs and web servers.
What are the main features of Express.js?
Main features include middleware support, routing, HTTP utility methods, and easy integration with templating engines.
How do you create a simple server using Express.js?
Use require(‘express’), create an app with express(), and start it with app.listen(port), e.g., app.get(‘/’, (req, res) => res.send(‘Hello’)).
What is middleware in Express.js?
Middleware are functions that have access to the request and response objects, used for tasks like logging, authentication, or parsing.
How do you define routes in Express.js?
Define routes using app.get(), app.post(), etc., with a path and callback, e.g., app.get(‘/users’, (req, res) => res.send(‘Users’)).
How do you handle errors in Express.js?
Use a middleware with four parameters (err, req, res, next) to catch and handle errors, e.g., app.use((err, req, res, next) => res.status(500).send(err)).
What is the role of the next function in middleware?
The next function passes control to the next middleware function in the stack, allowing sequential processing.
How do you handle form data and file uploads in Express.js?
Use middleware like body-parser for form data and multer for file uploads, configuring them to parse req.body or req.files.
How can you manage different environments in an Express.js application?
Use environment variables with process.env, and switch configurations (e.g., dev, prod) using a config file or package like dotenv.
What are some common security best practices when using Express.js?
Use Helmet for headers, sanitize inputs, enable CORS appropriately, use HTTPS, and validate/escape data to prevent attacks.
What is React.js?
React.js is a JavaScript library for building user interfaces, especially single-page applications, using a component-based architecture.
What are the main features of React.js?
Main features include virtual DOM, component reusability, JSX, hooks, and efficient updates via a diffing algorithm.
What is JSX?
JSX is a syntax extension for JavaScript that allows writing HTML-like code within React components, which is transpiled to JavaScript.
What are components in React.js?
Components are reusable building blocks in React that encapsulate UI and logic, either as functional or class-based entities.