use('test_FreePlanet'); let passo1 = [ ] let passo2 = [ ] let passo2b = [ ]; let passo3 = [ ]; let aggregation = []; let test = false; if (test) { aggregation = [...aggregation, ...passo4]; } else { aggregation = [...aggregation, ...passo1]; aggregation = [...aggregation, ...passo2]; aggregation = [...aggregation, ...passo2b]; aggregation = [...aggregation, ...passo3]; } db.users.aggregate(aggregation);