Home / Class/ XataHttpSession Class — drizzle-orm Architecture

XataHttpSession Class — drizzle-orm Architecture

Architecture documentation for the XataHttpSession class in session.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  c5129061_5764_d876_3e0b_d0817994976c["XataHttpSession"]
  dc9eb55a_1416_8b51_1561_0f80fbda9f7f["session.ts"]
  c5129061_5764_d876_3e0b_d0817994976c -->|defined in| dc9eb55a_1416_8b51_1561_0f80fbda9f7f
  4c48a572_178e_b1d2_a141_041f29df70a5["constructor()"]
  c5129061_5764_d876_3e0b_d0817994976c -->|method| 4c48a572_178e_b1d2_a141_041f29df70a5
  c4df918e_f053_8a30_32e0_48963a8c61b8["prepareQuery()"]
  c5129061_5764_d876_3e0b_d0817994976c -->|method| c4df918e_f053_8a30_32e0_48963a8c61b8
  58c4c1d6_1192_ca8e_f254_d9eb2e3e7f82["query()"]
  c5129061_5764_d876_3e0b_d0817994976c -->|method| 58c4c1d6_1192_ca8e_f254_d9eb2e3e7f82
  95dc96b7_5664_3355_07b3_0e98748a3243["queryObjects()"]
  c5129061_5764_d876_3e0b_d0817994976c -->|method| 95dc96b7_5664_3355_07b3_0e98748a3243
  89eefe25_bb07_e22b_cac7_3573bd8d9436["transaction()"]
  c5129061_5764_d876_3e0b_d0817994976c -->|method| 89eefe25_bb07_e22b_cac7_3573bd8d9436

Relationship Graph

Source Code

drizzle-orm/src/xata-http/session.ts lines 98–174

export class XataHttpSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig>
	extends PgSession<
		XataHttpQueryResultHKT,
		TFullSchema,
		TSchema
	>
{
	static override readonly [entityKind]: string = 'XataHttpSession';

	private logger: Logger;
	private cache: Cache;

	constructor(
		private client: XataHttpClient,
		dialect: PgDialect,
		private schema: RelationalSchemaConfig<TSchema> | undefined,
		private options: XataHttpSessionOptions = {},
	) {
		super(dialect);
		this.logger = options.logger ?? new NoopLogger();
		this.cache = options.cache ?? new NoopCache();
	}

	prepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(
		query: Query,
		fields: SelectedFieldsOrdered | undefined,
		name: string | undefined,
		isResponseInArrayMode: boolean,
		customResultMapper?: (rows: unknown[][]) => T['execute'],
		queryMetadata?: {
			type: 'select' | 'update' | 'delete' | 'insert';
			tables: string[];
		},
		cacheConfig?: WithCacheConfig,
	): PgPreparedQuery<T> {
		return new XataHttpPreparedQuery(
			this.client,
			query,
			this.logger,
			this.cache,
			queryMetadata,
			cacheConfig,
			fields,
			isResponseInArrayMode,
			customResultMapper,
		);
	}

	async query(query: string, params: unknown[]): Promise<QueryResults<'array'>> {
		this.logger.logQuery(query, params);
		const result = await this.client.sql({ statement: query, params, responseType: 'array' });

		return {
			rowCount: result.rows.length,
			rows: result.rows,
			rowAsArray: true,
		};
	}

	async queryObjects(query: string, params: unknown[]): Promise<QueryResults<'json'>> {
		const result = await this.client.sql<Record<string, any>>({ statement: query, params });

		return {
			rowCount: result.records.length,
			rows: result.records,
			rowAsArray: false,
		};
	}

	override async transaction<T>(
		_transaction: (tx: XataTransaction<TFullSchema, TSchema>) => Promise<T>,
		// eslint-disable-next-line @typescript-eslint/no-unused-vars
		_config: PgTransactionConfig = {},
	): Promise<T> {
		throw new Error('No transactions support in Xata Http driver');
	}
}

Domain

Frequently Asked Questions

What is the XataHttpSession class?
XataHttpSession is a class in the drizzle-orm codebase, defined in drizzle-orm/src/xata-http/session.ts.
Where is XataHttpSession defined?
XataHttpSession is defined in drizzle-orm/src/xata-http/session.ts at line 98.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free