CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/postgresql-node-best-practices

PostgreSQL patterns for Node.js with pg — connection pooling, parameterized

99

1.75x
Quality

99%

Does it follow best practices?

Impact

100%

1.75x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

task.mdevals/scenario-2/

Content Publishing Platform

Problem/Feature Description

A media company is building a content publishing platform backend with Node.js, TypeScript, and Express. The service uses PostgreSQL via the pg package. The database is accessible via a DATABASE_URL environment variable.

The platform needs to support:

  • Creating an article with title, body, author_id, status (draft/published/archived), and tags (an array of strings). The author must exist in the authors table -- if they don't, creation should fail with a clear error.
  • Publishing an article: sets status to "published" and published_at to the current time. If the article is already published, return a clear error.
  • Bulk importing articles from a CSV ingest pipeline -- receives an array of 50-500 articles that must be written efficiently
  • Searching articles by multiple tags (find articles matching ANY of the given tags)
  • Listing articles filtered by multiple statuses (e.g. show "draft" and "published" but not "archived")
  • Getting a single article by ID

Tables needed:

  • authors: id (serial), name, email (unique), created_at
  • articles: id (serial), title, body (text), author_id (FK to authors), status, tags (text[]), published_at (nullable), created_at, updated_at

Output Specification

Produce:

  • db.ts -- Database connection module
  • articles.ts -- Functions for all six operations listed above
  • package.json -- With required dependencies
  • migrations/001_create_tables.sql -- SQL migration for both tables

The code should be complete TypeScript with no placeholders or TODO comments.

evals

tile.json