MongoDB - Study24x7
Social learning Network
mongodb1 Cover image
mongodb1
MongoDB
  • Followers
  • Latest Feeds
  • Articles
  • Question
  • Course
  • About
  • Review
Interests
Databases
5 followers study24x7 27 Dec 2024 12:42 PM study24x7 study24x7

How would you find documents where the 'age' field exists and is not equal to 25?

A

db.collection.find({age: {$ne: 25, $exists: true}})

B

db.collection.find({age: {$exists: true, $ne: 25}})

C

db.collection.find({age: {$not: 25}})

D

db.collection.find({age: {$exists: true}, age: {$ne: 25}})

study24x7
Write a comment
5 followers study24x7 27 Dec 2024 12:41 PM study24x7 study24x7

How do you write a query to find documents where 'status' is either 'A' or 'D'?

A

db.collection.find({status: {$in: ["A", "D"]}})

B

db.collection.find({status: ["A", "D"]})

C

db.collection.find({status: {$or: ["A", "D"]}})

D

db.collection.find({$or: [{status: "A"}, {status: "D"}]})

study24x7
Write a comment
5 followers study24x7 27 Dec 2024 12:40 PM study24x7 study24x7

Which MongoDB operator would you use to find documents where the 'age' field is greater than 30?

A

$gt

B

$gte

C

$lt

D

$lte

study24x7
Write a comment
5 followers study24x7 26 Dec 2024 11:30 AM study24x7 study24x7

In a MongoDB query, what does using the $expr operator allow you to do?

A

Compare fields from the same document

B

Perform aggregation functions in a query

C

Use regular expressions in queries

D

None of the above

study24x7
Write a comment
5 followers study24x7 26 Dec 2024 11:30 AM study24x7 study24x7

What is the role of the $elemMatch operator in MongoDB queries?

A

To match documents where at least one element in an array matches the specified query conditions

B

To find the first element in an array that matches a condition

C

To apply a match condition to each element of an array

D

To update elements in an array based on a condition

study24x7
Write a comment
5 followers study24x7 26 Dec 2024 11:29 AM study24x7 study24x7

How does the $not operator function in MongoDB?

A

It negates the query condition specified

B

It selects documents that do not contain the field

C

It replaces the value of a field with null if the condition is true

D

It checks for values not equal to the specified value

study24x7
Write a comment
5 followers study24x7 24 Dec 2024 12:35 PM study24x7 study24x7

What is the purpose of the $and operator in MongoDB queries?

A

To perform a logical AND operation on an array of two or more expressions

B

To compare two fields in the same document

C

To add new fields to documents

D

To update data in a document conditionally

study24x7
Write a comment
5 followers study24x7 24 Dec 2024 12:34 PM study24x7 study24x7

What does the $in operator do in a MongoDB query?

A

Selects documents where a field's value is any of the specified array values

B

Changes the value of a field to one within a specified array

C

Counts how many times a field's value appears in a specified array

D

None of the above

study24x7
Write a comment
5 followers study24x7 24 Dec 2024 12:28 PM study24x7 study24x7

Which operator is used in MongoDB to select documents where a field equals a specified value?

A

$eq

B

$set

C

$match

D

$get

study24x7
Write a comment
5 followers study24x7 23 Dec 2024 11:45 AM study24x7 study24x7

Spot the error:
See more

A

The $sort stage is misplaced

B

The $match stage is using incorrect criteria

C

The $group stage has an error in the grouping key

D

No error

study24x7
Write a comment
5 followers study24x7 23 Dec 2024 11:44 AM study24x7 study24x7

What could be wrong if db.collection.createIndex({email: 1}, {unique: true}) fails to enforce uniqueness?

A

The collection already has duplicate emails

B

The index is not properly configured

C

The 'email' field is not indexed

D

MongoDB does not support unique indexes

study24x7
Write a comment
5 followers study24x7 23 Dec 2024 11:44 AM study24x7 study24x7

Why might an aggregation pipeline return incorrect results after adding a new index?

A

The index is not being used

B

The index is corrupt

C

The index has caused a change in the data order

D

The pipeline does not support indexing

study24x7
Write a comment
5 followers study24x7 20 Dec 2024 10:27 AM study24x7 study24x7

Identify the error in this command:
See more

A

Incorrect index type

B

Incorrect field name

C

Syntax error in the index specification

D

No error

study24x7
Write a comment
5 followers study24x7 20 Dec 2024 10:26 AM study24x7 study24x7

How can you create a text index on two fields, 'title' and 'description', in MongoDB?

A

db.collection.createIndex({title: "text", description: "text"})

B

db.collection.createTextIndex({title, description})

C

db.collection.addTextIndex({title, description})

D

db.collection.createIndex({title: 1, description: 1}, {type: "text"})

study24x7
Write a comment
5 followers study24x7 20 Dec 2024 10:25 AM study24x7 study24x7

What is the purpose of the $match stage in MongoDB's aggregation pipeline?

A

To sort documents

B

To group documents

C

To filter documents based on criteria

D

To limit the number of documents

study24x7
Write a comment
5 followers study24x7 19 Dec 2024 12:53 PM study24x7 study24x7

How do you create a descending index on the 'age' field in MongoDB?

A

db.collection.createIndex({age: -1})

B

db.collection.createIndex({age: "desc"})

C

db.collection.createIndex({age: 0})

D

db.collection.createIndex({age: "descending"})

study24x7
Write a comment
5 followers study24x7 19 Dec 2024 12:44 PM study24x7 study24x7

Which command creates a simple index on the 'name' field in MongoDB?

A

db.collection.createIndex({name: 1})

B

db.collection.index({name: 1})

C

db.collection.addIndex({name: 1})

D

db.collection.setIndex({name: 1})

study24x7
Write a comment
5 followers study24x7 19 Dec 2024 12:43 PM study24x7 study24x7

What is the impact of indexing on write performance in MongoDB?

A

It improves write performance

B

It has no impact

C

It can slow down write performance

D

It varies depending on the document size

study24x7
Write a comment
5 followers study24x7 18 Dec 2024 11:34 AM study24x7 study24x7

How does the $group stage in the aggregation pipeline operate?

A

It sorts the documents

B

It filters the documents

C

It groups documents by specified criteria

D

It merges documents into a single document

study24x7
Write a comment
5 followers study24x7 18 Dec 2024 11:33 AM study24x7 study24x7

In MongoDB, what is a covered query?

A

A query that only needs indexes to return results

B

A query that retrieves all fields of a document

C

A query that updates data

D

A query that requires sorting

study24x7
Write a comment
Ratings
0.0
out of 5
0 Ratings
5 study24x7
 
0.0
4 study24x7
 
0.0
3 study24x7
 
0.0
2 study24x7
 
0.0
1 study24x7
 
0.0
Related Pages