Last active
February 11, 2020 07:06
-
-
Save samparsky/f168b6abd2ffd9168eade45dcf71c60e to your computer and use it in GitHub Desktop.
EventAggregate with Channel lookup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ | |
| { | |
| "$lookup":{ | |
| "from":"channels", | |
| "localField":"channelId", | |
| "foreignField":"id", | |
| "as":"channel" | |
| } | |
| }, | |
| { | |
| "$addFields":{ | |
| "channel":{ | |
| "$arrayElemAt":[ | |
| "$channel", | |
| 0 | |
| ] | |
| } | |
| } | |
| }, | |
| { | |
| "$addFields":{ | |
| "leader":{ | |
| "$arrayElemAt":[ | |
| "$channel.spec.validators", | |
| 0 | |
| ] | |
| }, | |
| "follower":{ | |
| "$arrayElemAt":[ | |
| "$channel.spec.validators", | |
| 1 | |
| ] | |
| } | |
| } | |
| }, | |
| { | |
| "$addFields":{ | |
| "value":{ | |
| "$subtract":[ | |
| "$value", | |
| { | |
| "$multiply":[ | |
| "$value", | |
| { | |
| "$divide":[ | |
| { | |
| "$add":[ | |
| { | |
| "$toLong":"$leader.fee" | |
| }, | |
| { | |
| "$toLong":"$follower.fee" | |
| } | |
| ] | |
| }, | |
| { | |
| "$toLong":"$channel.depositAmount" | |
| } | |
| ] | |
| } | |
| ] | |
| } | |
| ] | |
| } | |
| } | |
| } | |
| ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment