Conduit
Conduit
Docsllms.txtHostingGitHubIntroduction

Getting Started

OverviewInstall ConduitMCP SetupYour First AppStart with AI

Learn

ArchitectureClient vs Admin APIConfiguration

Modules

OverviewAuthenticationAuthorizationDatabaseStorageCommunicationsChatRouterFunctions

Guides

Next.js IntegrationReBAC Team ScopingGitOps State Export

Deployment

Deployment OverviewDocker ComposeKubernetes and HelmLocal from SourceContainer Images

Reference

CLI ReferenceClient APIAdmin APIEnvironment VariablesMCP Tools

Resources

Migration v0.16 → v0.17Legacy DocumentationChangelogFAQGlossaryContributing

Database

Schemas, CRUD, custom endpoints, indexes, query trees, and GitOps export.

Your app needs structured data, but connecting to MongoDB or PostgreSQL directly bypasses Conduit auth, authorization, and routing. The database module is the data layer: you define schemas, enable CMS CRUD routes for simple access, and provision custom endpoints for every filtered query.

The most common mistake is calling GET /database/{Schema} and filtering in application code. That route runs findMany({}, …) — there is no filter parameter. Any WHERE clause, ownership scope, date range, or text search belongs in a provisioned custom endpoint at /database/function/{name}.

Use cases

App data models

Define Project, Order, Profile schemas with typed fields and CRUD routes

Filtered lists

Custom endpoints with query trees for WHERE, search, and pagination

Multi-tenant records

Authorization-enabled schemas with scope on create

Brownfield databases

Introspect existing collections via Admin API, finalize as CMS schemas

Config-as-code

Export schemas, extensions, and custom endpoints in GitOps state snapshots

Capabilities

  • MongoDB & PostgreSQL
  • Schema definitions & extensions
  • CMS CRUD routes
  • Custom endpoints & query trees
  • Comparison operators (eq, in, contains, …)
  • Indexes
  • Populate relations
  • Text search (like: true)
  • Database introspection (Admin API)
  • GitOps export (schemas, extensions, endpoints)
  • GraphQL (via router)

Example: Schema + custom endpoint (no client-side filter)

Walkthrough

  1. Create Post schema via MCP post_database_schemas with cms CRUD enabled
  2. Provision GetPostsByAuthor custom endpoint with authorId input and query tree filter
  3. Add an index on authorId for performance
  4. App calls GET /database/function/GetPostsByAuthor?authorId=USER_ID — never GET /database/Post then filter in JS
List via custom endpoint
curl "http://localhost:3000/database/function/GetPostsByAuthor?authorId=507f1f77bcf86cd799439011" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Create document
curl -X POST http://localhost:3000/database/Post \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"title":"Hello","body":"First post","authorId":"507f1f77bcf86cd799439011"}'

How it works

Schemas

A schema declares field types, indexes, and conduitOptions that control runtime behavior:

conduitOptions keyEffect
cms.enabledRegister CMS routes for this schema
cms.crudOperations.*.enabledPer-operation route exposure (create, read, update, delete)
cms.crudOperations.*.authenticatedRequire bearer token on that operation
authorization.enabledReBAC ownership tuples on documents — pass scope on creates
permissions.*Admin-panel schema permissions (separate from document ReBAC)

Schema extensions add fields to module-owned schemas (e.g. extend the auth User schema). Extensions are database-owned and included in GitOps export alongside base schemas.

Provision schemas at dev/deploy time via MCP post_database_schemas or patch_database_schemas_id. Module-owned schemas cannot be overwritten by import.

CMS CRUD

When conduitOptions.cms flags are set, the Client API exposes:

IntentHTTPPath
List (unfiltered)GET/database/{Schema}?skip&limit&sort&populate&scope
Get by idGET/database/{Schema}/{id}
CreatePOST/database/{Schema}?scope
UpdatePATCH/database/{Schema}/{id}
DeleteDELETE/database/{Schema}/{id}

List queries accept skip, limit, sort, and populate (GraphQL-style relation joins on REST). On authorization-enabled schemas, pass scope (e.g. Team:abc) on creates so ownership tuples attach to the right resource.

GET /database/{Schema} always queries with an empty filter {}. Use it only when a full collection scan (with pagination) is intentional.

Custom endpoints

Custom endpoints map to Client API routes at /database/function/{name}. Provision via MCP post_database_customendpoints.

FieldPurpose
operationHTTP verb: 0 GET, 1 POST, 2 PUT, 3 DELETE, 4 PATCH
selectedSchema / selectedSchemaNameTarget schema
inputsParameters (location: 0 body, 1 query, 2 URL)
queryQuery tree for read/update/delete filters
assignmentsField writes for POST/PUT/PATCH
authenticationRequire bearer token (mandatory on authorization-enabled schemas)
paginatedRequire skip + limit inputs
sortedEnable sort parameter

Query trees nest AND / OR arrays of leaf nodes. Each leaf has schemaField, operation, and comparisonField:

{
  "AND": [
    {
      "schemaField": "authorId",
      "operation": 0,
      "comparisonField": { "type": "Input", "value": "authorId" }
    }
  ]
}

comparisonField.type is Input (from endpoint params), Schema (field value from the matched document), Custom (fixed value), or Context (request context path).

Set comparisonField.like: true for case-insensitive text search ($ilike); caseSensitiveLike: true uses $like. On PostgreSQL, $ilike maps to ILIKE via the Sequelize adapter. On MongoDB, both operators are supported natively. Avoid like: true on non-text field types.

Comparison operations

OpNameBSON / behavior
0Equal{ field: value }
1Not equal{ field: { $ne: value } }
2Greater than{ field: { $gt: value } }
3Greater or equal{ field: { $gte: value } }
4Less than{ field: { $lt: value } }
5Less or equal{ field: { $lte: value } }
6In set{ field: { $in: value } } — value must be an array
7Not in set{ field: { $nin: value } }
8Contains (reserved)Same as Equal (0) — { field: value }

Op 8 does not implement array-contains yet. Use MongoDB $in / element-match patterns via custom logic until this operator is completed.

Assignment actions (write endpoints)

For POST/PUT/PATCH endpoints, assignments map inputs to schema fields:

ActionNameEffect
0SetAssign field value
1Increment$inc positive
2Decrement$inc negative
3Append$push (array fields only; PUT only)
4Remove$pull (array fields only; PUT only)

Database introspection

When you already have collections or tables outside Conduit, introspection discovers them and registers pending schemas for review. Finalize pending schemas to convert them into CMS schemas (CRUD disabled by default on imported schemas).

Introspection is an operator workflow on the Admin API (GET/POST /database/introspection, pending schema routes). These routes are marked mcp: false — no MCP tools exist for introspection. Use the Admin Panel or direct Admin API calls with admin credentials.

Large MongoDB collections can slow introspection; PostgreSQL introspection improved in recent releases.

GitOps export

The database module participates in platform state export/import. Exportable resource types:

TypePriorityContents
schemas10CMS schema definitions
extensions11Database-owned schema extensions
customEndpoints20Custom endpoint definitions

Use GET /state/export and POST /state/import on the Admin API, or module-scoped GET /database/schemas/export and GET /database/customEndpoints/export. See GitOps state export.

POST /database/schemas/import is also excluded from MCP (mcp: false) — prefer /state/import or Admin API directly in CI pipelines.

Configure

Enable the database module in deployment, then provision via MCP with ?modules=database:

post_database_schemas
patch_database_schemas_id
post_database_customendpoints
patch_database_customendpoints_id
post_database_schemas_id_indexes
patch_config_database
Config keyMeaning
readPreferenceMongoDB replica read preference (primary, secondaryPreferred, …)
writeConcernMongoDB write concern (1, majority)
readConcernMongoDB read concern (local, majority, …)

Sequelize/PostgreSQL caveats: index creation via Admin API is limited, case-sensitive $like behavior differs by dialect, and partial-row updates only change provided columns.

Client API

OperationPath
CRUD/database/{SchemaName}
Custom endpoint/database/function/{endpointName}
GraphQL/graphql (via router)

MCP

Enable with ?modules=database in your MCP server URL.

ToolPurpose
get_database_schemasList schemas
post_database_schemasCreate schema
patch_database_schemas_idUpdate schema
get_database_customendpointsList custom endpoints
post_database_customendpointsCreate custom endpoint
patch_database_customendpoints_idUpdate custom endpoint
post_database_schemas_id_indexesAdd index
patch_config_databaseReplica set / DB engine settings

Not exposed via MCP: introspection routes (/database/introspection/*), POST /database/schemas/import. Use Admin API or Admin Panel for those operator workflows.

Next steps

  • Your first app
  • Authorization & scope
  • GitOps state export
  • Client API reference
  • MCP tools

Authorization

ReBAC resources, relations, permissions, indexing, and scope.

Storage

File uploads, cloud providers (S3, Azure, GCS), signed URLs, public access, folder markers, and Prometheus metrics.

On this page

Use casesCapabilitiesExample: Schema + custom endpoint (no client-side filter)How it worksConfigureClient APIMCP