[SERVER-69791] need $addToSetIfNotLast operator Created: 17/Sep/22  Updated: 20/Sep/22  Resolved: 20/Sep/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 6.1.0-rc2
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Andrew Hodel Assignee: Edwin Zhou
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

This would allow for unique if not last entry into arrays.

 

Preventing:

 

```

['one', 'one', 'two', 'three']

```

 

But allowing:

 

```

['one', 'two', 'three', 'one']

```

 

$addToSet was created because you cannot be expected to use locks at the database level when there is request logic on the server that depends on TCP because a the TCP timeout being able to block everything else.

 

It's reasonable to expect that you would want unique if not last entries into an array.



 Comments   
Comment by Andrew Hodel [ 20/Sep/22 ]

I added this as a feature request -
https://feedback.mongodb.com/forums/924280-database/suggestions/45718594--addtosetifnotexists-or-javascript-code-as-array-o

Comment by Andrew Hodel [ 20/Sep/22 ]

I realize the problem of tracking feature requests because they are often irrational.

This however, is a probe into db operations on array fields being incomplete. It is a bug.

Perhaps it should be more than another operator.

Thank You,
Andrew Hodel

>

Comment by Andrew Hodel [ 20/Sep/22 ]

This is a bug.

The db operations on arrays are incomplete.

Thank You,
Andrew Hodel

>

Comment by Edwin Zhou [ 20/Sep/22 ]

Thank you for your feature request! I can see how this behavior would be valuable for inserting array entries in the pattern you've described. However, this JIRA project is for bug reports, but you can help get this on the radar by submitting a feature request to our MongoDB Feedback Engine.

You may also want to search and post on the MongoDB Developer Community Forums, as it's possible there are others who have guidance on how to satisfy your use-case.

Best,
Edwin

Generated at Thu Feb 08 06:14:24 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.