# Convex Cookbook: Dynamic Query Builders

DevFeed: [Convex Cookbook: Dynamic Query Builders](<https://devfeed.tech/articles/convex-cookbook-dynamic-query-builders-81342.md>)

Original publisher: [Read original article](<https://stack.convex.dev/dynamic-query-builders>)

Author: Stack

Published: 2025-01-07T17:40:00Z

Content type: tutorial

Language: en

Sources: [Stack](<https://devfeed.tech/sources/stack.md>)

Topics: [Query (disambiguation)](<https://devfeed.tech/topics/query.md>), [Test-driven development](<https://devfeed.tech/topics/tdd.md>)

Tags: [article](<https://devfeed.tech/tags/article.md>), [backend](<https://devfeed.tech/tags/backend.md>), [behavior](<https://devfeed.tech/tags/behavior.md>), [body](<https://devfeed.tech/tags/body.md>), [boolean](<https://devfeed.tech/tags/boolean.md>), [build](<https://devfeed.tech/tags/build.md>), [builder](<https://devfeed.tech/tags/builder.md>), [building](<https://devfeed.tech/tags/building.md>), [convex](<https://devfeed.tech/tags/convex.md>), [copilot](<https://devfeed.tech/tags/copilot.md>), [cursor](<https://devfeed.tech/tags/cursor.md>), [database](<https://devfeed.tech/tags/database.md>), [filter](<https://devfeed.tech/tags/filter.md>), [order](<https://devfeed.tech/tags/order.md>), [patterns](<https://devfeed.tech/tags/patterns.md>), [queries](<https://devfeed.tech/tags/queries.md>), [query](<https://devfeed.tech/tags/query.md>), [query-builders](<https://devfeed.tech/tags/query-builders.md>), [recipe](<https://devfeed.tech/tags/recipe.md>), [runtime](<https://devfeed.tech/tags/runtime.md>), [structure](<https://devfeed.tech/tags/structure.md>), [write](<https://devfeed.tech/tags/write.md>)

## AI overview

This tutorial shows how to build Convex database queries dynamically in TypeScript while respecting the type constraints on indexes, ordering, and search. It explains how to separate query construction into stages and notes that applying multiple index filters requires a post-filter or a multi-field index.

## Source excerpt

You can write a Convex query whose structure -- which index/order/filters to apply, if any -- depends on runtime factors. This article gives a recipe for building queries dynamically.