Mongodb aggregation problem

  mongodb, question
The data structure in mongodb is as follows
 {'_id': 1, 'a': 10, 'b': 20}
 
 The required structure is
 _a: a*2
 _b: a*2+b
 
 db.getCollection('XXX').aggregate({
 $project:{
 _a: {$multiply:['$a', 2]},
 _b: {$add:['$this._a', '$b']}
 }
 })

How do I use the calculated _a value here

First, understand how aggregation works. If you know linux, it works like a pipeline. The results of one pipeline calculation can be used in the next pipeline. However, if it is used in the same pipeline, it can only be recalculated.

db.getCollection('XXX').aggregate({
 $project:{
 _a: {$multiply:['$a', 2]},
 _b: {$add:[{$multiply:['$a', 2]}, '$b']}
 }
 });

Or in the next pipeline

db.getCollection('XXX').aggregate({
 $project: {
 _a: {$multiply:['$a', 2]},
 b: '$b'
 },
 $project: {
 _a: '$_a',
 _b: {$add: ['$_a', '$b']}
 });