Home / Function/ toValueParam() — drizzle-orm Function Reference

toValueParam() — drizzle-orm Function Reference

Architecture documentation for the toValueParam() function in index.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  16976e3f_1e84_95cc_287d_48a3e730c2ee["toValueParam()"]
  70aad088_e19b_50e8_495f_75e687b514dc["index.ts"]
  16976e3f_1e84_95cc_287d_48a3e730c2ee -->|defined in| 70aad088_e19b_50e8_495f_75e687b514dc
  19e5b6c7_e0b0_fe9a_9ee8_4529ae6d428a["values()"]
  19e5b6c7_e0b0_fe9a_9ee8_4529ae6d428a -->|calls| 16976e3f_1e84_95cc_287d_48a3e730c2ee
  8c4377f8_2d7b_dd42_14a3_bb5333d4c3dc["typingsToAwsTypeHint()"]
  16976e3f_1e84_95cc_287d_48a3e730c2ee -->|calls| 8c4377f8_2d7b_dd42_14a3_bb5333d4c3dc
  style 16976e3f_1e84_95cc_287d_48a3e730c2ee fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-orm/src/aws-data-api/common/index.ts lines 60–97

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

Called By

Frequently Asked Questions

What does toValueParam() do?
toValueParam() is a function in the drizzle-orm codebase, defined in drizzle-orm/src/aws-data-api/common/index.ts.
Where is toValueParam() defined?
toValueParam() is defined in drizzle-orm/src/aws-data-api/common/index.ts at line 60.
What does toValueParam() call?
toValueParam() calls 1 function(s): typingsToAwsTypeHint.
What calls toValueParam()?
toValueParam() is called by 1 function(s): values.

Analyze Your Own Codebase

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

Try Supermodel Free