Retrieves the first record matching the query for a given primary key.
This function is useful for fetching a single record based on a primary key.
It automatically routes the query to the correct shard based on the provided
primary key, ensuring consistent data access.
Promise that resolves to the first matching record, or null if not found
Throws
If query fails or routing fails
Example
typeUser = { id: string; name: string; email: string; }; // Get a specific user constuserResult = awaitfirst<User>('user-123', 'SELECT * FROM users WHERE id = ?', ['user-123'] );
if (userResult) { console.log(`Found user: ${userResult.name}`);
Retrieves the first record matching the query for a given primary key.
This function is useful for fetching a single record based on a primary key. It automatically routes the query to the correct shard based on the provided primary key, ensuring consistent data access.