Database

Docs

Relational databases are for structured data you query by fields and relationships. This demo stores the same product catalog used in Vector Search in PostgreSQL, then queries it with Drizzle by price, rating, and keywords. Use a database when exact filters and transactions matter. Use Vector Search when meaning matters more than exact fields.

Seed the database with 6 sample chair products, then run queries.

Query Results

Select a query and run it to see results.

Tip: The vector demo found these same chairs by meaning. This demo finds them by exact criteria — same data, different query model.

Reference Code
import { gte, ilike, lt } from "drizzle-orm";
import { drizzle } from "drizzle-orm/node-postgres";
import { pgTable, real, serial, text } from "drizzle-orm/pg-core";
import { Pool } from "pg";

const products = pgTable("products", {
  id: serial("id").primaryKey(),
  sku: text("sku").notNull().unique(),
  name: text("name").notNull(),
  price: real("price").notNull(),
  avgRating: real("avg_rating").notNull(),
});

const pool = new Pool({
  connectionString: process.env.DATABASE_URL,
});

const db = drizzle(pool, { schema: { products } });

const budget = await db
  .select()
  .from(products)
  .where(lt(products.price, 200));

const topRated = await db
  .select()
  .from(products)
  .where(gte(products.avgRating, 4.5));

const search = await db
  .select()
  .from(products)
  .where(ilike(products.name, "%Ergo%"));

await pool.end();

export { budget, topRated, search };
Ready
Output will appear here...