Stage not supported inside of a multi-document transaction: $unionWith

I’m implementing own cusomized foreignkey control by using aggregate unionWith ensure all record exists before create new document.

I’m stuck at situation which is I need to insert multiple record for multiple collection. After first record created 2nd record wish to use aggregate+unionWith search first record exists, and 3rd record will use aggregate+unionWith first and 2nd record exists.

I’m tested 2 approach and both no luck

  1. run aggregate without transaction session, it tell me record not found cause transaction not yet commit
  2. apply aggregate with transaction session, but it block $unionWith Stage not supported inside of a multi-document transaction: $unionWith.

So far anyway to allow unionWith work under transaction? Split foreignkey check using search 1 by 1 is not good option cause it create too much execution.

Hope there is some genius answer from you guys