How to convert below MongoDB query into PHP?
Below query worked fine in Studio 3T and Robomongo, But I want to convert it into PHP format, Following is my query, db.news.aggregate([ { $match: { "_id" : "1" } }, { "$project": { "comments": { "$filter": { "input": "$comments", "as": "comment", "cond": { "$eq": [ "$$comment.status", "active" ] } } } } }, { "$project": { "comments": { "$slice": [ { "$slice": [ "$comments", { "$subtract": [ { "$size": [ "$comments" ] }, 1 ] } ] }, -1 ] } } }]) I have tried below, But it giving error " Error: localhost:27017: FieldPath field names may not be empty strings. " PHP converted sample: <?php