This is BSON document. I want only those entries whose attribute length is greater than zero
/* 1 */
{
"_id" : "http://exhentai.org",
"length" : 0,
"value" : ""
}
/* 2 */
{
"_id" : "http://vuclip.com",
"length" : 77,
"value" : "vuclip scroll learn official weve launched close news team pressroom linkedin"
}
/* 3 */
{
"_id" : "http://hbogo.com",
"length" : 174,
"value" : "hbo hbo anywhere hbo enjoy instant unlimited access every episode every season best hbo shows movies comedy sports documentaries hbo free subscription participating providers"
}
So output should be
/* 2 */
{
"_id" : "http://vuclip.com",
"length" : 77,
"value" : "vuclip scroll learn official weve launched close news team pressroom linkedin"
}
/* 3 */
{
"_id" : "http://hbogo.com",
"length" : 174,
"value" : "hbo hbo anywhere hbo enjoy instant unlimited access every episode every season best hbo shows movies comedy sports documentaries hbo free subscription participating providers"
}
What I tried
db.coll.aggregate([
{$project: {
Text:
{
$cond: { if: { $gte: [ "$length", 20 ] }, then: "$value" }
}
_id : 0
}}
])