MongoDB.live, free & fully virtual. June 9th - 10th. Register Now

Mongodb aggregate. How to apply a function to a field

As part of an aggregate I need to run this transformation:

{ $eq: [ "$_id", sha256( { $toString: "$creatorId" } ) ] },

creatorId comes from a lookup, and in order to compare it to _id I first need to do a sha256.

How can I do it?

Thanks.

Ah I looked into same thing, few days ago;

There is a request ticket open, and waiting for a long time… it is at https://jira.mongodb.org/browse/SERVER-30359

@Eduardo_Cobian let me know if you find a workaround.

1 Like