zenstack icon indicating copy to clipboard operation
zenstack copied to clipboard

Pass computed properties to Zenstack Query Hooks in Vue

Open 0x15F9 opened this issue 1 year ago • 1 comments

I have configured zenstack for nuxt js and I am using the tanstack-query plugin. I would like to fetch data using useFindMany{} and in the where clause set the value based from a ref or computed property. How should I proceed?

0x15F9 avatar Sep 03 '24 18:09 0x15F9

The way you should do it is to make the whole first argument a computed property. Not just the where clause

genu avatar Sep 04 '24 12:09 genu

@0x15F9 please see comments from @genu . Closing for now.

ymc9 avatar Nov 08 '24 01:11 ymc9

An example would be helpful

On Fri, 08 Nov 2024, 5:07 am Yiming, @.***> wrote:

@0x15F9 https://github.com/0x15F9 please see comments from @genu https://github.com/genu . Closing for now.

— Reply to this email directly, view it on GitHub https://github.com/zenstackhq/zenstack/issues/1683#issuecomment-2463551720, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEDH7ZFBEBEDNDRM2SW4ILDZ7QFDJAVCNFSM6AAAAABNSWWVFWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINRTGU2TCNZSGA . You are receiving this because you were mentioned.Message ID: @.***>

0x15F9 avatar Nov 08 '24 03:11 0x15F9

You can do something like this:

const { data } = useFindFirstPost(
    computed(() => ({ where: { id: id.value } }))
)

genu avatar Nov 08 '24 04:11 genu

Thanks for the tip!

On Fri, 08 Nov 2024, 8:42 am Eugen Istoc, @.***> wrote:

You can do something like this:

const { data } = useFindFirstPost( computed(() => ({ where: { id: id.value } })) )

— Reply to this email directly, view it on GitHub https://github.com/zenstackhq/zenstack/issues/1683#issuecomment-2463753869, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEDH7ZESXJHIADOLDWAOGPLZ7Q6LLAVCNFSM6AAAAABNSWWVFWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINRTG42TGOBWHE . You are receiving this because you were mentioned.Message ID: @.***>

0x15F9 avatar Nov 08 '24 05:11 0x15F9

I'll add something to the docs 😄

ymc9 avatar Nov 08 '24 19:11 ymc9

Awesome, thank you so much!

On Fri, 08 Nov 2024, 11:00 pm Yiming, @.***> wrote:

I'll add something to the docs 😄

— Reply to this email directly, view it on GitHub https://github.com/zenstackhq/zenstack/issues/1683#issuecomment-2465547950, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEDH7ZD4Q7O5HCJMN5QTYF3Z7UC5TAVCNFSM6AAAAABNSWWVFWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINRVGU2DOOJVGA . You are receiving this because you were mentioned.Message ID: @.***>

0x15F9 avatar Nov 09 '24 01:11 0x15F9