Apply suggestions from code review

This commit is contained in:
Copple authored and GitHub committed 2022-03-22 16:48:27 +01:00
1 parent 4f14ab937a
commit d24d012bfc
1 file changed
+1 -23
+1 -23
View File
@@ -371,30 +371,8 @@ pages:
};
```
To get more from the generated types, optionally you can use [`postgrest-js-tools`](https://github.com/mzalevski/postgrest-js-tools).
For more advance type-support, check out [`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