Skip to main content
Version: Next

Database Service

The Database Service is a core service type that runs within Watt (the Node.js Application Server). It automatically generates GraphQL and REST APIs from your database schema, eliminating the need to write boilerplate CRUD operations.

The Database Service supports PostgreSQL, MySQL, MariaDB, and SQLite, automatically introspecting your database schema to create type-safe, fully-featured APIs with support for relationships, filtering, pagination, and real-time subscriptions.

For a high level overview of how Watt and its services work, please reference the Overview guide.

Features

Automatic API Generation

  • REST/OpenAPI: Automatically generate a complete REST API from your database schema
  • GraphQL: Create a GraphQL API with full query, mutation, and subscription support
  • Interactive Documentation: Access API docs via Scalar and GraphiQL IDE
  • Apollo Federation: Extend your API with federation support

Database Support

  • Multi-Database: Works with PostgreSQL, MySQL, MariaDB, and SQLite
  • Schema Introspection: Automatically discovers tables, relationships, and constraints
  • Migrations: Efficient database migrations with version control
  • Type Safety: Generated TypeScript definitions based on your schema

Authentication and Authorization

Complete flexibility

Usage

  • Integrate Platformatic DB programmatically into your tests or other applications for more dynamic usage.

Quick Start

The easiest way to create a Database Service is within a Watt application:

# Create a new Watt application
wattpm create my-app

# This will prompt you to add a Database Service
cd my-app

# Start in development mode
wattpm dev

Your Database Service will automatically generate REST and GraphQL APIs based on your database schema. Visit the interactive documentation at http://localhost:3042/documentation to explore your APIs.

For service-specific configuration and advanced usage, see the Configuration guide.

When to Use Database Service

Database Service is perfect when you need:

  • Rapid API Development: Get CRUD APIs instantly without writing boilerplate code
  • Database-First Design: Build APIs that directly reflect your database structure
  • Multiple API Formats: Support both REST and GraphQL clients from the same service
  • Real-time Features: Built-in GraphQL subscriptions for live data updates
  • Enterprise Features: Advanced authorization, migrations, and schema management
info

Ready to start? Check out our Getting Started Guide to create your first Watt application with a Database Service! ⚡

Supported databases

DatabaseVersion
SQLite3.x
PostgreSQL>= 15
MySQL>= 5.7
MariaDB>= 10.11

The database driver is automatically loaded based on the value connectionString configuration setting.

Issues

If you run into a bug or have a suggestion for improvement, please raise an issue on GitHub or join our Discord feedback channel.