I have type= user
documents in this form:
{
type: ‘user’,
name: …,
companyName: ‘acmeWidgets’,
email: …,
primaryPhone: ‘888-888-888’,
userDefinedProperties: [
{
type: ‘phoneNumber’,
value: ‘777-777-777’
},
{
type: ‘favoriteColor’,
value: ‘blue’
},
{
type: ‘phoneNumber’,
value: ‘222-222-2222’
}
]
}
I want to query a collection of these objects projecting the company, and array of phone numbers, like so:
{
companyName: ‘acmeWidgets’,
phonenumbers: [‘888-888-888’, ‘777-777-777’, ‘222-222-222’]
}
The ‘primaryPhone’ field on the object may or may not be defined. And one or more or none of the userDefinedProperties will have the target type=‘phoneNumber’
So I have to do
Select
companyName,
??? as phonenumbers
From default
Where type = ‘user’
Please help.