Groups
Sign in
Groups
Morphia
Conversations
About
Send feedback
Help
Aggregation query to get size of list
11 views
Skip to first unread message
Vaishnavi Manjunath
unread,
Oct 12, 2017, 4:18:27 AM
10/12/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Morphia
Hi,
I am trying to count the number of elements in a list of each document in a collection, similar to below example. (
https://docs.mongodb.com/manual/reference/operator/aggregation/size/#exp._S_size
)
I am unable to arrive at an equivalent morphia query to achieve the same.
Any help in this regard would be greatly appreciated.
Thanks,
db
.
inventory
.
aggregate
(
[
{
$project
:
{
item
:
1
,
numberOfColors
:
{
$size
:
"$colors"
}
}
}
]
)
Reply all
Reply to author
Forward
0 new messages