-
Let's take a query of the form:
We can chain multiple such clauses. But how does drizzle know when the chaining has stopped and it's time to execute the query? For example, I could add another clause after limit(), such as offset(). How does drizzle figure out whether more clauses are coming, or its the end of the line? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
One of the reasons I ask is: I want to conditionally append a clause. For example, I want to specify limit() only in certain condition. Can I store the partially constructed builder in a variable and then apply limit() conditionally ? |
Beta Was this translation helpful? Give feedback.
-
ChatGPT to the rescue: The query is executed automatically when you await the query object. This is because Drizzle ORM overrides the then() method of the query object, which is a part of the promise interface in JavaScript. |
Beta Was this translation helpful? Give feedback.
ChatGPT to the rescue:
The query is executed automatically when you await the query object. This is because Drizzle ORM overrides the then() method of the query object, which is a part of the promise interface in JavaScript.
When you await a query, JavaScript internally calls the then() method of the query object, at which point Drizzle compiles the SQL statement and executes it against the database.