C100DEV MongoDB Overview and Document Model Practice Question
A developer is building a MongoDB application to store user profiles. Each profile document includes a field `lastLogin` that records the exact date and time of the user's most recent login. The developer wants to ensure that this field is stored using the most appropriate BSON type for date and time values, allowing for efficient range queries and sorting. Which BSON type should be used for the `lastLogin` field?
⚠ Common exam trap
Watch out — candidates often confuse the BSON Timestamp type, which is for internal replication use, with the Date type that is meant for application date storage.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Date
The BSON Date type is the standard for storing date and time values in MongoDB. It provides millisecond precision and integrates with query operators like `$gt`, `$lt`, and aggregation date operators. Using it for a `lastLogin` field ensures accurate temporal comparisons and efficient indexing. Other types like String or Timestamp are either inefficient or semantically incorrect for application-level timestamps.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Timestamp
Why it's wrong here
The BSON Timestamp type is a special internal type used primarily for replication and sharding metadata, such as the oplog. It is not intended for application-level date and time storage. While it stores seconds and an increment, it lacks the millisecond precision and calendar semantics needed for typical user activity timestamps like a last login.
- ✓
Date
Why this is correct
The BSON Date type stores a 64-bit integer representing milliseconds since the Unix epoch, making it ideal for storing exact points in time. It supports efficient range queries, sorting, and date aggregation operators. For a `lastLogin` field, using Date ensures correct temporal ordering and enables queries like finding users who logged in within the last 24 hours.
- ✗
ObjectId
Why it's wrong here
ObjectId is a 12-byte unique identifier typically used for the `_id` field. It embeds a timestamp but is not designed to represent arbitrary date and time values. Using ObjectId for `lastLogin` would make it difficult to query by date ranges and would not provide the expected date-specific operators, leading to confusion and potential errors in date handling.
- ✗
String
Why it's wrong here
Storing the date and time as a string would require a consistent, sortable format such as ISO 8601, and range queries would rely on lexicographic comparison, which is less efficient and error-prone. MongoDB provides a dedicated Date type for temporal data, so using a string here would forgo built-in date operators and proper indexing behavior for time-based queries.
About these practice questions
One of 259 original C100DEV practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official MongoDB exam blueprint
This C100DEV practice question is part of Courseiva's free MongoDB certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the C100DEV exam.