Skip to content

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

docs: update snaplet example for seeding (#18155)

Julien Goux73690101bd04
diff --git a/apps/docs/pages/guides/cli/seeding-your-database.mdx b/apps/docs/pages/guides/cli/seeding-your-database.mdx
index e704e90c757..9afc71f7d9a 100644
--- a/apps/docs/pages/guides/cli/seeding-your-database.mdx
+++ b/apps/docs/pages/guides/cli/seeding-your-database.mdx
@@ -67,21 +67,18 @@ We can use the Snaplet configuration file to define the values you want to gener
- Three `Post.comments` from three different users.
```ts snaplet.config.ts
-defineConfig({
+import { defineConfig } from 'snaplet'
+import { copycat } from '@snaplet/copycat'
+
+export default defineConfig({
generate: {
- plan(snaplet) {
- return snaplet.Post({
- data: {
- title: "There is a lot of snow around here!"
- User: {
- data: {
- email: copycat.email(seed, { domain: 'acme.org' })
- }
- },
- Comment: {
- count: 3,
- }
- }
+ async run(snaplet) {
+ await snaplet.posts({
+ title: "There is a lot of snow around here!"
+ userByCreatedBy: {
+ email: copycat.email(seed, { domain: 'acme.org' })
+ },
+ comments: (x) => x(3)
})
}
}
@@ -111,7 +108,7 @@ INSERT INTO "User" (name, email) VALUES ("Steven Plank", "[email protected]")
INSERT INTO "Comment" (text, userId, postId) VALUES ("Actually, that's not correct...", 4, 1)
```
-For more information, check out Snaplet's ["generate" documentation](https://docs.snaplet.dev/references/data-operations/generate)
+For more information, check out Snaplet's ["generate" documentation](https://docs.snaplet.dev/getting-started/quick-start/generate)
export const Page = ({ children }) => <Layout meta={meta} children={children} />