File tree Expand file tree Collapse file tree 1 file changed +24
-15
lines changed
graphql/resolvers/Freight Expand file tree Collapse file tree 1 file changed +24
-15
lines changed Original file line number Diff line number Diff line change @@ -130,22 +130,31 @@ export default {
130130 const conditions = { ...resto } ;
131131 if ( vehicles ) conditions . vehicles = { vehicles : { $in : vehicles } } ;
132132 if ( bodies ) conditions . bodies = { bodies : { $in : bodies } } ;
133- const res = await Freight . aggregate ( [
134- {
135- $geoNear : {
136- near : { type : "Point" , coordinates } ,
137- distanceField : "dist.calculated" ,
138- spherical : true ,
139- key : "origin.location" ,
140- includeLocs : "location" ,
141- maxDistance : range ,
142- query : conditions
143- }
144- } ,
145- ...freightquery ,
146- { $skip : ( page - 1 ) * perpage } ,
147- { $limit : perpage }
133+ const list = await Freight . aggregate ( [
134+ ...freightquery
135+ // { $out: "aggr_out" }
148136 ] ) . exec ( ) ;
137+
138+ console . log ( list ) ;
139+
140+ const res = await list
141+ . aggregate (
142+ {
143+ $geoNear : {
144+ near : { type : "Point" , coordinates } ,
145+ distanceField : "dist.calculated" ,
146+ spherical : true ,
147+ key : "origin.location" ,
148+ // includeLocs: "location",
149+ maxDistance : range ,
150+ query : conditions
151+ }
152+ } ,
153+ { $skip : ( page - 1 ) * perpage } ,
154+ { $limit : perpage }
155+ )
156+ . exec ( ) ;
157+
149158 return freightfinalquery ( res , conditions , page , perpage ) ;
150159 }
151160 } ,
You can’t perform that action at this time.
0 commit comments