Server-Side Computing Model Quiz (Lec5)

ExcitingRhodonite3899 avatar
ExcitingRhodonite3899
·
·
Download

Start Quiz

Study Flashcards

40 Questions

Which method is used to insert a document into a MongoDB collection?

insertOne

What is the purpose of the find method in MongoDB?

To query and retrieve documents from a collection

How can you limit the number of documents returned by a find query in MongoDB?

By using the limit method

Which method is used to update a document in a MongoDB collection?

updateOne

What is the purpose of the _id field in MongoDB?

To uniquely identify a document

Which of the following best describes a callback function in Node.js?

A callback function is a function that is passed as an argument into another function and can be invoked inside the outer function.

What is the purpose of using callback functions in Node.js?

To make the program asynchronous and prevent I/O blocking.

What is the typical structure of a callback function in Node.js?

function(err, results) { // code to be executed }

What is the purpose of the first argument in a callback function in Node.js?

To pass an Error object if an error occurred.

When using callback functions in Node.js, what happens if no error occurred during the operation?

The first argument of the callback function should be null.

Which of the following is NOT a step in creating a MongoDB document?

Close MongoDB connection

What is the purpose of the 'required' validator in Mongoose?

To ensure that a field must have a value

Which validator can be used to specify a range for a number field in Mongoose?

Min

What is the purpose of the 'enum' validator in Mongoose?

To validate that a field can only have specific values

What is the purpose of the 'match' validator in Mongoose?

To validate the format of a field

Which of the following best describes Mongoose?

A tool for building MongoDB object modeling in Node.js

What does ODM stand for in the context of Node.js?

Object Document Mapper

How can you install Mongoose?

Both A and B

What are Schemas in Mongoose?

They describe the data construct of a document and define the name and type of data

How can you connect to MongoDB using Mongoose?

By using the mongoose.connect() function

Which of the following is the correct way to install the MongoDB Node.js driver?

Use npm to install the MongoDB Node.js driver.

What is the purpose of the Waterfall pattern in JavaScript callback functions?

To waterfall through function chains and handle errors in the original invoking function.

What are the two most common HTTP methods for a request-response between a client and a server?

GET and POST

What is the purpose of the 'npm start' command in Node.js app development?

To run the startup script specified in the package.json file.

What is the purpose of the 'assert' module in the MongoDB Node.js driver?

To check for connection and insertion errors.

Which of the following is true about Base64 encoding?

Base64 encoding schemes are commonly used for storing and transferring binary data.

Which of the following is true about GridFS?

GridFS divides a file into parts, or chunks, and stores each chunk as a separate document.

What is the maximum size of a BSON document in MongoDB?

16 megabytes

What are the two collections used by GridFS to store files?

chunks and metadata

What is the purpose of using GridFS?

To store and retrieve files that exceed 16 megabytes in size

What is the purpose of Base64 encoding?

The purpose of Base64 encoding is to encode binary data in a way that it can be stored and transferred over media designed to deal with textual data. It ensures that the data remains intact without modification during transport.

What is the maximum size of a BSON document in MongoDB?

The maximum size of a BSON document in MongoDB is 16MB.

What is GridFS?

GridFS is a specification for storing and retrieving files that exceed the BSON-document size limit of 16 megabytes. It divides a file into parts, or chunks, and stores each of those chunks as a separate document.

What are the two collections used by GridFS to store files?

GridFS uses two collections to store files: the chunks collection, which stores the file chunks, and the files collection, which stores the file metadata.

What is the purpose of using GridFS?

GridFS is useful for storing files that exceed 16 megabytes, as well as for storing any files that you want to access without having to load the entire file into memory.

What are the pros and cons of storing album details in a database and photos in a filesystem?

Pros: Allows for efficient storage and retrieval of album details and photos separately. Cons: Requires managing two separate storage systems, may introduce complexity in synchronizing album details and photos.

What are the pros and cons of storing album details and photos in a database?

Pros: Simplifies storage and retrieval by keeping all data in one system. Cons: May introduce performance issues with large files, may require additional configuration for handling binary data.

What is the purpose of the 'assert' module in the MongoDB Node.js driver?

The 'assert' module is used for basic assertion testing in the MongoDB Node.js driver. It is used to check if a given condition is true and throw an error if it is not.

What is the purpose of the 'findOne' method in MongoDB?

The 'findOne' method is used to query a collection in MongoDB and retrieve the first document that matches the specified criteria.

What is the purpose of the 'mimetype' field in the GridFS file metadata?

The 'mimetype' field in the GridFS file metadata is used to store the MIME type of the file, which indicates the type of data contained in the file.

Test your knowledge of building a MongoDB app with Node.js. Explore example code and learn how to display HTML forms and allow users to send GET requests for finding or removing MongoDB documents.

Make Your Own Quizzes and Flashcards

Convert your notes into interactive study material.

Get started for free

More Quizzes Like This

Use Quizgecko on...
Browser
Browser