{
"_id" : ObjectId("5b4d975be2194da53a85e69f"),
"ISBN" : 2,
"book_title" : "ZERO TO ONE",
"author_name" : "Peter Theil",
"publisher" : "Penguin",
"status" : "ISSUED",
"issued" : [
{
"member_name" : "suresh",
"member_id" : 101,
"from_date" : "1/01/2018",
"to_date" : "15/02/2018"
},
{
"member_name" : "Jay",
"member_id" : 103,
"from_date" : "16/02/2018",
"to_date" : "30/03/2018"
}
]}
This is my Mongodb Document format.What i want to do is Count array length of issued of each document. So my Output will be Count:2 for this document. I want to implement this with spring data mongodb. I referred there documentation and found there is a Size class for this in ArrayOperators class Link here:
Spring data mongodb Documentaion
But i am don't know Use Size class ???
Mongodb terminal query is:
db.library.aggregate([{$project:{count:{$size:"$issued"},"book_title":1,"_id":0}])