Allow Dynamic Object In $project and $addFields
Assume I have a field mapping defined in some configuration collection of my application. And this field mapping varies for different clients on my application.
I would like to pass the dynamic object in my $project or $addFields stage
Like:
$project: {
{$arrayToObject: "$field_mapping"},
}
{$arrayToObject: "$field_mapping"} would return something like
"email" : "$data.Email",
"phone" : "$data.Phone,
"firstname" : "$data.FirstName",
"lastname" : "$data.LastName",
"preferredchannel" : "$data.Channel",
"preferredlanguage" : "$data.LanguageCode",
"emailchannel" : "$data.Email",
"smschannel" : "$data.SMS",
"province" : "$data.CustomerState"
1
vote
Abdul Moiz
shared this idea