Mike
Mike
PPrisma
Created by Mike on 4/21/2025 in #help-and-questions
How can I perform batch updates unique entities in Prisma?
How can I perform batch updates in Prisma — akin to createMany — by passing an array or collection to a single operation? I’m working inside long-lived interactive transactions and need to update multiple records by their unique IDs. What’s the best approach? 1. Using Promise.all([ tx.model.update(…)*N ]) for each item 2. Writing a custom extension or helper with an SQL builder 3. Executing raw SQL via tx.$executeRaw Could you also show an example SQL query that accomplishes this? (I’m not very familiar with SQL, so any guidance is appreciated.)
WITH updates (id, new_name, new_status) AS (
VALUES
(1, 'Alice', 'active'),
(2, 'Bob', 'pending'),
(5, 'Charlie', 'banned')
)
UPDATE users u
SET
name = updates.new_name,
status = updates.new_status
FROM updates
WHERE u.id = updates.id;
WITH updates (id, new_name, new_status) AS (
VALUES
(1, 'Alice', 'active'),
(2, 'Bob', 'pending'),
(5, 'Charlie', 'banned')
)
UPDATE users u
SET
name = updates.new_name,
status = updates.new_status
FROM updates
WHERE u.id = updates.id;
5 replies
PPrisma
Created by Mike on 3/13/2025 in #help-and-questions
WILDCARD, New index type for MongoDB
I want to thank the Prisma team for the quick response to my previous request, especially @Nurul. My current question is: how do I add a new type of indexes for MongoDB, what is the flow for implementing this feature, where should I start, and what tests should I add? My question: https://github.com/prisma/prisma/discussions/26165#discussioncomment-12220940 Docs: https://www.mongodb.com/docs/manual/core/indexes/index-types/index-wildcard/
5 replies
PPrisma
Created by Mike on 2/27/2025 in #help-and-questions
mongodb compressors
How to add compressors to mongodb connection string?
19 replies