Skip to content

Commit

Permalink
chore: update playground
Browse files Browse the repository at this point in the history
  • Loading branch information
sandros94 committed May 28, 2024
1 parent 694fecb commit f2b5ecf
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions playground/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
{{ test ?? 'No Data' }}
</pre>
<pre>
{{ _version }}
{{ _items ?? _itemsError }}
</pre>
</div>
</div>
</template>

<script setup lang="ts">
import type { Response } from '../src/runtime/types'
import type { Res } from '../src/runtime/types'
interface Product {
id: string
Expand All @@ -34,17 +34,22 @@ interface Product {
price: number
currency: string
}
const { items, sql, $sql, version } = useSurrealDB()
const { data: _items, error: _itemsError } = await items<Res<Product[]>>('products', {
transform: (data: any) => {
return data[0].status === 'OK' ? data[0].result : []
},
})
const { sql, $sql, version } = useSurrealDB()
const test = ref<Response<Product[]> | undefined>()
const test = ref<Res<Product[]> | undefined>()
async function fetchSql() {
test.value = await $sql<Product[]>('SELECT * FROM products;', {
test.value = await $sql<Res<Product[]>>('SELECT * FROM products;', {
database: 'staging',
})
}
const { data, error } = await sql('SELECT * FROM products;')
const { data, error } = await sql<Res<Product[]>>('SELECT * FROM products;')
const { data: _version } = await version({
database: 'staging',
})
Expand Down

0 comments on commit f2b5ecf

Please sign in to comment.