MCPcopy Create free account
hub / github.com/ChatLab/ChatLab / getSchemaDetailed

Function getSchemaDetailed

packages/core/src/query/message-queries.ts:454–483  ·  view source on GitHub ↗
(db: DatabaseAdapter)

Source from the content-addressed store, hash-verified

452 * Returns table names + full column info via PRAGMA table_info.
453 */
454export function getSchemaDetailed(db: DatabaseAdapter): TableSchema[] {
455 const tables = db
456 .prepare(
457 `SELECT name FROM sqlite_master
458 WHERE type='table' AND name NOT LIKE 'sqlite_%'
459 ORDER BY name`
460 )
461 .all() as Array<{ name: string }>
462
463 return tables.map((table) => {
464 const columns = db.prepare(`PRAGMA table_info('${table.name}')`).all() as Array<{
465 cid: number
466 name: string
467 type: string
468 notnull: number
469 dflt_value: unknown
470 pk: number
471 }>
472
473 return {
474 name: table.name,
475 columns: columns.map((col) => ({
476 name: col.name,
477 type: col.type,
478 notnull: col.notnull === 1,
479 pk: col.pk === 1,
480 })),
481 }
482 })
483}
484
485// ==================== Context & Conversation Queries ====================
486

Callers 2

registerSqlRoutesFunction · 0.90
getSchemaFunction · 0.90

Calls 2

allMethod · 0.65
prepareMethod · 0.65

Tested by

no test coverage detected