swajp
swajp5mo ago

how can i access the roomCode and redirect user

export const create = mutation({
handler: async ctx => {
const game = await ctx.db.insert("games", {
roomCode: generateRoomCode(),
round: 1,
currentWord: generateRandomWord()
})

return game
}
})
export const create = mutation({
handler: async ctx => {
const game = await ctx.db.insert("games", {
roomCode: generateRoomCode(),
round: 1,
currentWord: generateRandomWord()
})

return game
}
})
const onCreate = () => {
create().then(room => {
router.push(`/game/${room.roomCode}`)
})
}
const onCreate = () => {
create().then(room => {
router.push(`/game/${room.roomCode}`)
})
}
and i get Property 'roomCode' does not exist on type 'string & { __tableName: "games"; }'.ts(2339)
1 Reply
sshader
sshader5mo ago
db.insert returns an ID, not the document itself. Either use db.get to load the document you just wrote, or return the room code directly

Did you find this page helpful?