Created
May 8, 2024 09:30
-
-
Save nikolasburk/e0da110abf3c24eba2907d12bf6e5fa7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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