useQuery()
function useQuery<T>(
query,
sqlParameters,
options): WatchedQueryResult<T>
A composable to access the results of a watched query.
Type parameters
Type parameter | Value |
---|---|
T | any |
Parameters
Parameter | Type | Default value |
---|---|---|
query | MaybeRef <string | CompilableQuery <T >> | undefined |
sqlParameters | MaybeRef <any []> | [] |
options | AdditionalOptions | {} |
Returns
WatchedQueryResult
<T
>
Example
<script setup>
import { useQuery } from '@powersync/vue';
const { data, isLoading, isFetching, error} = useQuery('SELECT * FROM lists');
</script>
<template>
<div v-if="isLoading">Loading...</div>
<div v-else-if="isFetching">Updating results...</div>
<div v-if="error">{{ error }}</div>
<ul v-else>
<li v-for="l in data" :key="l.id">{{ l.name }}</li>
</ul>
</template>