index.ts — drizzle-orm Source File
Architecture documentation for index.ts, a typescript file in the drizzle-orm codebase. 2 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR 70aad088_e19b_50e8_495f_75e687b514dc["index.ts"] c1888528_22f2_78cd_a2b9_80fc9f29b8f3["client-rds-data"] 70aad088_e19b_50e8_495f_75e687b514dc --> c1888528_22f2_78cd_a2b9_80fc9f29b8f3 be483a7f_d5d7_7a9b_9a13_44a4a6aafbbd["sql.ts"] 70aad088_e19b_50e8_495f_75e687b514dc --> be483a7f_d5d7_7a9b_9a13_44a4a6aafbbd e8d52f5f_2316_1b4f_9799_7155b57c23ff["session.ts"] e8d52f5f_2316_1b4f_9799_7155b57c23ff --> 70aad088_e19b_50e8_495f_75e687b514dc style 70aad088_e19b_50e8_495f_75e687b514dc fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import type { Field } from '@aws-sdk/client-rds-data';
import { TypeHint } from '@aws-sdk/client-rds-data';
import type { QueryTypingsValue } from '~/sql/sql.ts';
export function getValueFromDataApi(field: Field) {
if (field.stringValue !== undefined) {
return field.stringValue;
} else if (field.booleanValue !== undefined) {
return field.booleanValue;
} else if (field.doubleValue !== undefined) {
return field.doubleValue;
} else if (field.isNull !== undefined) {
return null;
} else if (field.longValue !== undefined) {
return field.longValue;
} else if (field.blobValue !== undefined) {
return field.blobValue;
// eslint-disable-next-line unicorn/no-negated-condition
} else if (field.arrayValue !== undefined) {
if (field.arrayValue.stringValues !== undefined) {
return field.arrayValue.stringValues;
}
if (field.arrayValue.longValues !== undefined) {
return field.arrayValue.longValues;
}
if (field.arrayValue.doubleValues !== undefined) {
return field.arrayValue.doubleValues;
}
if (field.arrayValue.booleanValues !== undefined) {
return field.arrayValue.booleanValues;
}
if (field.arrayValue.arrayValues !== undefined) {
return field.arrayValue.arrayValues;
}
throw new Error('Unknown array type');
} else {
throw new Error('Unknown type');
}
}
export function typingsToAwsTypeHint(typings?: QueryTypingsValue): TypeHint | undefined {
if (typings === 'date') {
return TypeHint.DATE;
} else if (typings === 'decimal') {
return TypeHint.DECIMAL;
} else if (typings === 'json') {
return TypeHint.JSON;
} else if (typings === 'time') {
return TypeHint.TIME;
} else if (typings === 'timestamp') {
return TypeHint.TIMESTAMP;
} else if (typings === 'uuid') {
return TypeHint.UUID;
} else {
return undefined;
}
}
export function toValueParam(value: any, typings?: QueryTypingsValue): { value: Field; typeHint?: TypeHint } {
const response: { value: Field; typeHint?: TypeHint } = {
value: {} as any,
typeHint: typingsToAwsTypeHint(typings),
};
if (value === null) {
response.value = { isNull: true };
} else if (typeof value === 'string') {
switch (response.typeHint) {
case TypeHint.DATE: {
response.value = { stringValue: value.split('T')[0]! };
break;
}
case TypeHint.TIMESTAMP: {
response.value = { stringValue: value.replace('T', ' ').replace('Z', '') };
break;
}
default: {
response.value = { stringValue: value };
break;
}
}
} else if (typeof value === 'number' && Number.isInteger(value)) {
response.value = { longValue: value };
} else if (typeof value === 'number' && !Number.isInteger(value)) {
response.value = { doubleValue: value };
} else if (typeof value === 'boolean') {
response.value = { booleanValue: value };
} else if (value instanceof Date) { // eslint-disable-line no-instanceof/no-instanceof
// TODO: check if this clause is needed? Seems like date value always comes as string
response.value = { stringValue: value.toISOString().replace('T', ' ').replace('Z', '') };
} else {
throw new Error(`Unknown type for ${value}`);
}
return response;
}
Domain
Subdomains
Dependencies
- client-rds-data
- sql.ts
Imported By
Source
Frequently Asked Questions
What does index.ts do?
index.ts is a source file in the drizzle-orm codebase, written in typescript. It belongs to the DrizzleORM domain, QueryBuilders subdomain.
What functions are defined in index.ts?
index.ts defines 3 function(s): getValueFromDataApi, toValueParam, typingsToAwsTypeHint.
What does index.ts depend on?
index.ts imports 2 module(s): client-rds-data, sql.ts.
What files import index.ts?
index.ts is imported by 1 file(s): session.ts.
Where is index.ts in the architecture?
index.ts is located at drizzle-orm/src/aws-data-api/common/index.ts (domain: DrizzleORM, subdomain: QueryBuilders, directory: drizzle-orm/src/aws-data-api/common).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free