The shard binding name to execute the query on
SQL statement to execute
Parameter values to bind to the SQL statement
Promise resolving to structured query results
// Administrative query: count all users across a specific shard
const eastCoastStats = await allShard('db-east',
'SELECT COUNT(*) as user_count FROM users'
);
console.log(`East coast users: ${eastCoastStats.results[0].user_count}`);
// Cross-shard analytics: get recent posts from a specific region
const recentPosts = await allShard('db-west',
'SELECT id, title, created_at FROM posts WHERE created_at > ? ORDER BY created_at DESC LIMIT ?',
[Date.now() - 86400000, 10] // Last 24 hours, limit 10
);
// Schema inspection on specific shard
const tables = await allShard('db-central',
"SELECT name FROM sqlite_master WHERE type='table'"
);
Bypasses the normal routing logic to execute a query directly on a specified shard. This is useful for administrative operations, cross-shard queries, or when you need to query data that doesn't follow the primary key routing pattern.
Use with caution: This function bypasses routing safeguards and should be used only when you specifically need to target a particular shard.