Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Add more information to Generating Types section

Maciej Zalewski4f14ab937aa4
diff --git a/web/spec/supabase.yml b/web/spec/supabase.yml
index d9d6124e714..01d538ec324 100644
--- a/web/spec/supabase.yml
+++ b/web/spec/supabase.yml
@@ -370,6 +370,31 @@ pages:
res.status(200).json(allOnlineUsers);
};
```
+
+ To get more from the generated types, optionally you can use [`postgrest-js-tools`](https://github.com/mzalevski/postgrest-js-tools).
+
+ Features:
+
+ - Intellisense while selecting fields (`getShape`).
+ - Return type based on the selected fields (`typeof shape`).
+ - Auto-generated select string (`getFields`).
+
+ ```
+ import { getShape, getFields } from "postgrest-js-tools";
+
+ const shape = getShape<definitions["users"]>()({
+ id: true,
+ status: true,
+ });
+
+ export default async (req: NextApiRequest, res: NextApiResponse) => {
+ const allOnlineUsers = await supabase
+ .from<typeof shape>("users")
+ .select(getFields(shape))
+ .eq("status", "ONLINE");
+ res.status(200).json(allOnlineUsers);
+ };
+ ```
### Update types automatically with GitHub Actions