Francismiko
Francismiko2y ago

How internalMutation is used in Scheduling functions in TypeScript

I'm running into some type issues. I followed the example in the documentation, but I don't understand how this type is defined, any better suggestions?
2 Replies
Francismiko
FrancismikoOP2y ago
How should I set the mutation function I pass in as ScheduledFunctionNames<API>
const destruct = internalMutation({
args: {
messageId: v.id('messages'),
},
handler: async ({ db }, { messageId }) => {
await db.delete(messageId)
},
})

...
await scheduler.runAfter(3000, 'sendExpiringMessage:destruct', { messageId })
const destruct = internalMutation({
args: {
messageId: v.id('messages'),
},
handler: async ({ db }, { messageId }) => {
await db.delete(messageId)
},
})

...
await scheduler.runAfter(3000, 'sendExpiringMessage:destruct', { messageId })
ballingt
ballingt2y ago
You need to export the destruct mutation, like export const destruct = internalMutation( ... )

Did you find this page helpful?