Readme

Connecting to Xata in Val Town

This val tests the viability of attaching to a Xata database via their Typescript SDK. The code for the getXataClient function can be found here.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Generated with CLI
import { getXataClient } from "https://esm.town/v/nbbaier/xata";
const xata = getXataClient({ branch: "hello" });
const page = await xata.db.Posts.select([
"id",
"title",
"labels",
"slug",
"text",
"createdAt",
"views",
"author.id",
"author.name",
"author.email",
"author.bio",
]).getPaginated({
pagination: {
size: 15,
},
});
export default page.records.slice(0, 2);
πŸ‘† This is a val. Vals are TypeScript snippets of code, written in the browser and run on our servers. Create scheduled functions, email yourself, and persist small pieces of data β€” all from the browser.