I wonder if anyone has used the prisma middleware ...
# orm-help
k
I wonder if anyone has used the prisma middleware to create a retry requests to the database? Is this a valid usecase?
Copy code
PrismaService.$use(async (params, next) => {
    console.log(params);
    let c = 0;
    let response;
    while (c < 5) {
        console.log("count", c);
        try {
            const result = await next(params);
            response = result;
            break;
        } catch (err) {
            c++;
            console.log(err);
            response = err;
        }
    }
    return response;
});
1
a
Hey Kay, You could definitely give this a shot! I’m not sure I’ve seen this done before, but I would love to hear about your experience with it.
k
@Austin ye i discuss it in this thread here https://github.com/prisma/prisma/discussions/15284
💯 1
🙌 1