Skip to content

Instantly share code, notes, and snippets.

@nikolasburk
Created May 8, 2024 09:30
Show Gist options
  • Save nikolasburk/e0da110abf3c24eba2907d12bf6e5fa7 to your computer and use it in GitHub Desktop.
Save nikolasburk/e0da110abf3c24eba2907d12bf6e5fa7 to your computer and use it in GitHub Desktop.
// VERSION 1
// subscribe to all changes on the `User` table
const s = await prisma.user.subscribe()
// wait for new events to arrive
for await (let event of s) {
// log the details about an event to the terminal
console.log(`Something happened in the database: `)
console.log(event)
}
// VERSION 2
// subscribe to all changes on the `User` table
const stream = await prisma.user.stream()
// wait for new events to arrive
for await (let event of s) {
// log the details about an event to the terminal
console.log(`Something happened in the database: `)
console.log(event)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment