File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -197,10 +197,17 @@ function tree(schema, options) {
197
197
recursive = recursive || false ;
198
198
199
199
if ( recursive ) {
200
- filters [ 'path' ] = { $regex : '^' + this . path + pathSeparator }
201
- }
202
- else {
203
- filters [ 'parent' ] = this . _id
200
+ if ( filters [ '$query' ] ) {
201
+ filters [ '$query' ] [ 'path' ] = { $regex : '^' + this . path + pathSeparator } ;
202
+ } else {
203
+ filters [ 'path' ] = { $regex : '^' + this . path + pathSeparator } ;
204
+ }
205
+ } else {
206
+ if ( filters [ '$query' ] ) {
207
+ filters [ '$query' ] [ 'parent' ] = this . _id ;
208
+ } else {
209
+ filters [ 'parent' ] = this . _id ;
210
+ }
204
211
}
205
212
206
213
return this . model ( this . constructor . modelName ) . find ( filters , fields , options , next ) ;
@@ -252,7 +259,11 @@ function tree(schema, options) {
252
259
ids . pop ( ) ;
253
260
}
254
261
255
- filters [ '_id' ] = { $in : ids } ;
262
+ if ( filters [ '$query' ] ) {
263
+ filters [ '$query' ] [ '_id' ] = { $in : ids } ;
264
+ } else {
265
+ filters [ '_id' ] = { $in : ids } ;
266
+ }
256
267
257
268
return this . model ( this . constructor . modelName ) . find ( filters , fields , options , next ) ;
258
269
} ;
You can’t perform that action at this time.
0 commit comments