How to query the below data -
{
"_id" : "0005b9cb-bdea-4a0e-a73e-58a87fa5502f",
"book" : {
"$ref" : "book",
"$id" : "530"
},
"groupddetails" : [
{
"$ref" : "group",
"$id" : "1017"
},
{
"$ref" : "group",
"$id" : "1016"
}
],
"isCourseBook" : false,
"isSample" : false,
"subscriptionDetailsList" : [
{
"_id" : "fcf944d5-2134-4a14-8a9a-9f8725fcf73e",
"subscriptionType" : "organization",
"activationDate" : ISODate("2015-08-24T18:31:00.000Z"),
"expiryDate" : ISODate("2016-02-19T18:29:00.000Z"),
"accessCode" : "dec81577-9736-4f0b-98c2-7b710a991979",
"isSample" : false
}
],
"user" : {
"$ref" : "user",
"$id" : "384eb921-683a-4cff-b837-cf4187db1299"
}
}
I want subscriptionType = 'organization'.
How can i filter out that data ?
---------------------------------------------------------------------------------------------------------------
Also, how can i get single column from the mongo collection? Please see below -
$this->src('ops')
->query(array("collection"=>"user_book_purchase"))
->pipe(new Filter(array(
array("subscriptionDetailsList","!=", NULL)
)))
->pipe(new Group(array(
"by"=>"_id",
"count"=>"cntval"
)))
->pipe(new Group(array(
"sum"=>"cntval"
)))
->pipe($this->dataStore('subscription_sold'));
I want a single column from collection.