Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Atomic scalar list operations #6250

Closed
jonahsnider opened this issue Mar 25, 2021 · 2 comments
Closed

Atomic scalar list operations #6250

jonahsnider opened this issue Mar 25, 2021 · 2 comments

Comments

@jonahsnider
Copy link

jonahsnider commented Mar 25, 2021

Problem

Scalar lists only support setting a value

This results in a less pleasant developer experience as well as potential data loss from race conditions.

Suggested solution

Add push (add elements) and pull (remove elements) operators.
Maybe also a pop operator.

Some thought should be put into the syntax used to push 1 element or 1+ elements. MongoDB uses an object with the $each operator:

db.students.update(
   { name: "joe" },
   { $push: { scores: { $each: [ 90, 92, 85 ] } } }
)

Additional context

Database documentation for array updates:

@jonahsnider
Copy link
Author

Just realized this is a (partial?) duplicate of #5078 and is partially solved by prisma/prisma-engines#1753.

@pantharshit00
Copy link
Contributor

pantharshit00 commented Mar 26, 2021

I will consider it as full duplicate of #5078 and it will available in the next release(which will hopefully happen on Tuesday 31-03. For deletion, you will need to use set as you can't uniquely identify them and there can be duplicates so it will be application specific logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants