Say, I have a collection of files, each file has path. I want to query all files at depth 2. Because the Db may contain a lot of files, I want to filter them on the server and not on the client. Basically I want something like the below, which obviously doesn't work
var FileSchema = new Schema({
path:String
});
var File = mongoose.model('File', FileSchema);
File
.find()
.where('path.split("/").length == 2')
.exec(function(err, files) {
...
});