Mongodb array query

  mongodb, question
{
 'a': 1,
 'b':2,
 'c': 3,
 'd': [
 {'e': 4, 'f': 5, 'g': 6},
 {'e': 0, 'f': '', 'g': 3},
 {'e': 1, 'f': '', 'g': 3},
 ]
 }
 {
 'a': 1,
 'b':2,
 'c': 3,
 'd': [
 {'e': 4, 'f': '', 'g': 6},
 {'e': 0, 'f': '', 'g': 3},
 {'e': 1, 'f': '', 'g': 3},
 ]
 }

For such a record, the problem is how to get the documents with all f in the d array empty (the result above is document 2)? Thank you

This is all I know$whereI don’t know how to realize it, nor do I know other methods for the time being.

pay attention to

If it is a regular query, it is strongly not recommended.$where, it traverses all documents, each fromBSONIt is converted into javascript objects and then processed through expressions, which is much slower than regular queries and is only used when there is no way out. Use regular queries to filter before using$whereThis combination can reduce performance loss. If it is possible to filter using the index first,$whereOnly for further filtering of results.
From Mongodb Authority Guide (E2)

Code:

db.collection.find({"$where":function(){
 var d = this.d, i = 0, j = d.length;
 for(i,j;  i<j;  i++){
 if(d[i].f !  = "")return false;
 };
 return true;
 }});