Sequence NODE_261
Easy

Design Basic User Collection Schema

MongoDB
Node.js
Technical Specification

Design a basic user document structure for MongoDB including name, email, passwordHash, roles, createdAt.

Input/Output Samples
Input:User signup
Output:{ name, email, passwordHash, roles: ['user'], createdAt }
Optimal Logic Path
// Example shape (no strict schema in MongoDB)
{
  name: "Happy",
  email: "happy@example.com",
  passwordHash: "hashed_password_here",
  roles: ["user"],
  createdAt: new Date(),
}
Architectural Deep-Dive
MongoDB stores flexible JSON-like documents, so we define a consistent shape for user documents.