IT 302 - Test2 [Unit 5 Quiz, Unit 6 Quiz, Unit 7 Quiz]
Which query language is primarily used to interact with MongoDB?
MongoDB Query Language (MQL)
In MongoDB, what is a document?
A JSON-like data structure
What is the uniform resource identifier (URI) in the context of RESTful APIs?
A string that uniquely identifies a resource on the web
What does MongoDB store its data in?
Collections
Which of the following best describes MongoDB's data model?
Document-Oriented
Which HTTP method is typically used for retrieving data from a resource in a RESTful API without causing any side effects?
GET
Which HTTP methods are commonly used in RESTful APIs to perform CRUD (Create, Read, Update, Delete) operations?
GET, POST, PUT, DELETE
In a Node.js project, what is the purpose of the node_modules directory?
It houses third-party npm packages and libraries used by the project.
What does the npm install command primarily do in a Node.js project?
It installs project dependencies listed in the package.json file.
What is the purpose of an ObjectId in MongoDB?
It is used as a primary key for documents.
What is the purpose of the $set operator in MongoDB's update function?
It sets a field to a specific value.
Which data format is commonly used for data exchange in RESTful APIs?
JSON
What does REST stand for in RESTful API?
Representational State Transfer
When specifying a filter in the updateOne method in MongoDB, how does the filter impact the operation when multiple documents in the collection match the filter criteria?
The first matching document encountered is updated, and the operation stops.
When using the deleteOne method in MongoDB, if no documents match the specified filter criteria, what is the result of the operation?
The method returns a success status, but no documents are deleted.
In the context of HTTP status codes, what does a "404" status code indicate?
The requested resource could not be found on the server.
In the context of RESTful API testing, which of the following is the main objective of using testing tools?
To automate requests and validate API functionality
What is the primary purpose of the Router class in Express.js?
To define and manage routes and route handlers for an Express application.
In Express.js, what is the primary purpose of the use method when applied to an Express application or router?
To define middleware functions that are executed for every request.
In a Node.js application that uses the MongoDB MongoClient, what is the purpose of using the await keyword when calling the connect method to connect to the database?
To ensure that database connection errors are caught and handled more effectively.
In the MongoDB Node.js library, what is the primary purpose of the MongoClient method?
To establish a connection to a MongoDB server and interact with databases.
What is the primary purpose of an HTTP status code in a RESTful API response?
To indicate the outcome of the request
What is the main purpose of the npm init command in a Node.js project?
To initialize a new Node.js project and create a package.json file.
What is the primary purpose of Nodemon in a Node.js development environment?
To monitor changes to files and automatically restart the Node.js application
What is the primary purpose of a middleware function in an Express.js application?
To perform processing on incoming HTTP requests or responses before they reach their final destination.
You want to retrieve books authored by "J.K. Rowling" and published after the year 2000. Which option demonstrates the correct way to specify both conditions using the find function?
db.books.find({author: "J.K. Rowling", year: {$gt: 2000}})
You want to retrieve only the "title" and "author" fields of books published in 2019 using the find function in MongoDB. Which option demonstrates the correct query?
db.books.find({year: 2019}, {title: 1, author: 1})
Given a MongoDB collection named "books" containing book documents with fields "title," "author," and "year," how do you find all books published in 2020 using the find function?
db.books.find({year: 2020})
You want to update a document in a MongoDB collection named "products" where the "product_id" is 123. Which option demonstrates the correct usage of the update function with the $set operator to update the "price" field to 19.99?
db.products.update({product_id: 123}, {$set: {price: 19.99}})
What is an advantage of using the insertOne method in MongoDB compared to other insert methods like insertMany?
insertOne provides the ability to insert a single document and obtain its generated _id.