[JAVA-3835] $set aggregation function is missing Created: 09/Sep/20  Updated: 28/Oct/23  Resolved: 17/Jun/21

Status: Closed
Project: Java Driver
Component/s: Builders
Affects Version/s: None
Fix Version/s: 4.3.0

Type: New Feature Priority: Major - P3
Reporter: Matthew Shaylor Assignee: Jeffrey Yemin
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Documentation Changes: Needed

 Description   

I'm trying to do a $set from java, I'd expect to be able to write something like:

 var iterable = collection.aggregate(Arrays.asList(
                Aggregates.set(fields(computed("foo", "bar)))
 ));

Am I missing something? Could this be added?

Thanks!



 Comments   
Comment by Githook User [ 17/Jun/21 ]

Author:

{'name': 'Matthew', 'email': 'github@shaylor.co.uk', 'username': 'Gaff'}

Message: Add $set method to Aggregates (#574)

JAVA-3835

Co-authored-by: mshaylor <mshaylor@mercuria.com>
Co-authored-by: Jeff Yemin <jeff.yemin@mongodb.com>
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/96d59ac62965acef59df6ce5d719fd7e0c0b6794

Comment by Jeffrey Yemin [ 09/Sep/20 ]

Currently we only have helpers for aggregation stages, not the operators, of which there are a lot more.

Comment by Matthew Shaylor [ 09/Sep/20 ]

Aha - I guess that's what I was missing!

I will use the workaround - but would be great if there was some more obvious clue about what's going on.

@Jeffrey Yemin: I also can't find $map, is there a workaround for that or do I just need to build up the documents by hand?

Comment by Jeffrey Yemin [ 09/Sep/20 ]

I think we didn't add it because, as stated in the documentation, it's an alias for $addFields, for which there is already a helper. So for now can you use that as a workaround?

Comment by Matthew Shaylor [ 09/Sep/20 ]

Have create a simple PR for this: https://github.com/mongodb/mongo-java-driver/pull/574

Generated at Thu Feb 08 09:00:33 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.