CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/mongoose-best-practices

Mongoose and MongoDB patterns — schema design, validation, indexes, virtuals,

99

1.11x
Quality

99%

Does it follow best practices?

Impact

100%

1.11x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

criteria.jsonevals/scenario-3/

{
  "context": "The agent designs data models and a feed function for a blogging platform. Criteria check whether the agent correctly embeds bounded author display data directly in the Post document rather than using populate, uses references for independently-queried Tags, implements cursor-based pagination instead of skip/limit, and applies lean() on the read-only feed query.",
  "type": "weighted_checklist",
  "checklist": [
    {
      "name": "author data embedded",
      "description": "Author display information (e.g., name, avatar) is embedded directly within the Post document schema rather than stored as a reference to a separate User/Author collection that would require populate",
      "max_score": 14
    },
    {
      "name": "no populate for author",
      "description": "The `getFeed` function does NOT call `.populate()` to retrieve author information — the data is already in the Post document",
      "max_score": 10
    },
    {
      "name": "tags as references",
      "description": "Tags are stored as references (ObjectId refs) in the Post schema rather than fully embedded, since tags exist independently and are shared across posts",
      "max_score": 12
    },
    {
      "name": "cursor-based pagination",
      "description": "The `getFeed` function uses a cursor value (e.g., filtering on `_id` with `$lt` or `$gt`) to paginate, NOT `skip()` with a page number",
      "max_score": 14
    },
    {
      "name": "no skip usage",
      "description": "The `getFeed` function does NOT use `.skip()` in its query chain",
      "max_score": 10
    },
    {
      "name": "limit plus one fetch",
      "description": "The `getFeed` function fetches one more document than the page size (limit + 1) to determine whether a next page exists",
      "max_score": 10
    },
    {
      "name": "nextCursor returned",
      "description": "The `getFeed` function returns a next cursor value (e.g., the last document's `_id`) alongside the results so the caller can fetch the next page",
      "max_score": 8
    },
    {
      "name": "lean on feed query",
      "description": "The `getFeed` query uses `.lean()` since the returned documents are sent directly to API responses and not modified",
      "max_score": 10
    },
    {
      "name": "timestamps on Post",
      "description": "The Post schema uses `timestamps: true` in its schema options",
      "max_score": 6
    },
    {
      "name": "status enum on Post",
      "description": "The Post schema defines the `status` field with an `enum` constraint (e.g., `['draft', 'published']`)",
      "max_score": 6
    }
  ]
}

evals

tile.json