Skip to content

Commit c957466

Browse files
Update src/pages/gen2/build-a-backend/data/connect-to-existing-database/index.mdx
Co-authored-by: Ivan Artemiev <29709626+iartemiev@users.noreply.github.com>
1 parent 7cbf394 commit c957466

File tree

1 file changed

+13
-9
lines changed
  • src/pages/gen2/build-a-backend/data/connect-to-existing-database

1 file changed

+13
-9
lines changed

src/pages/gen2/build-a-backend/data/connect-to-existing-database/index.mdx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,22 +128,26 @@ import { schema as rdsSchema } from './schema.rds.ts'
128128

129129
// Rename models or fields to be more idiomatic for frontend code
130130
// highlight-start
131-
rdsSchema.models.todos.renameTo("Todo")
132-
rdsSchema.models.todos.fields.title.renameTo("content")
133-
// highlight-end
131+
const modifiedRds = rdsSchema.renameModels(() => [
132+
['todo', 'Todo']
133+
]).renameModelFields((models) => [
134+
models.Todo.renameFields(() => [
135+
['title', 'content'],
136+
]),
137+
])
134138

135139
const schema = a.schema({
136-
Todo: a.model({
137-
content: a.string()
138-
isDone: a.boolean()
139-
})
140-
}).authorization([a.allow.public()])
140+
Post: a.model({
141+
title: a.string()
142+
}).authorization([a.allow.public()])
143+
})
141144

142145
const combinedSchema = a.schema.combine([
143146
schema,
144-
rdsSchema
147+
modifiedRds
145148
])
146149

150+
147151
export type Schema = typeof schema
148152
export const data = defineData({
149153
schema: combinedSchema

0 commit comments

Comments
 (0)