Mongoose and MongoDB patterns — schema design, validation, indexes, virtuals,
99
99%
Does it follow best practices?
Impact
100%
1.11xAverage score across 5 eval scenarios
Passed
No known issues
{
"context": "The agent writes a database connection module for a production Mongoose application. Criteria check whether the connection is configured with pool size and timeouts, error/disconnect events are handled, environment variables are used for the URI, and graceful shutdown is implemented for SIGTERM and SIGINT signals.",
"type": "weighted_checklist",
"checklist": [
{
"name": "maxPoolSize configured",
"description": "The `mongoose.connect` call includes a `maxPoolSize` option with a numeric value",
"max_score": 12
},
{
"name": "serverSelectionTimeoutMS set",
"description": "The `mongoose.connect` call includes `serverSelectionTimeoutMS` option",
"max_score": 8
},
{
"name": "socketTimeoutMS set",
"description": "The `mongoose.connect` call includes `socketTimeoutMS` option",
"max_score": 8
},
{
"name": "URI from environment variable",
"description": "The MongoDB URI is read from `process.env` (e.g., `process.env.MONGODB_URI`) rather than hardcoded as a string literal",
"max_score": 12
},
{
"name": "error event handler",
"description": "A listener is registered on `mongoose.connection` for the `'error'` event",
"max_score": 10
},
{
"name": "disconnected event handler",
"description": "A listener is registered on `mongoose.connection` for the `'disconnected'` event",
"max_score": 10
},
{
"name": "SIGTERM handler",
"description": "A `process.on('SIGTERM', ...)` handler is registered that closes the Mongoose connection before exiting",
"max_score": 12
},
{
"name": "SIGINT handler",
"description": "A `process.on('SIGINT', ...)` handler is registered that closes the Mongoose connection before exiting",
"max_score": 12
},
{
"name": "connection.close on shutdown",
"description": "The signal handlers call `mongoose.connection.close()` (not just `process.exit()`) to properly release connections before exiting",
"max_score": 10
},
{
"name": "await on connect",
"description": "The `mongoose.connect(...)` call is awaited (not fire-and-forget)",
"max_score": 6
}
]
}