@@ -21,7 +21,7 @@ import { getTypeName } from "../../util/naming-conventions";
21
21
import * as util from "./lib" ;
22
22
import * as Errors from '../../util/errors' ;
23
23
import Data from "../../types/Generic/Data" ;
24
- import Resource , { ResourceWithTypePath } from "../../types/Resource" ;
24
+ import { ResourceWithTypePath } from "../../types/Resource" ;
25
25
import ResourceIdentifier from "../../types/ResourceIdentifier" ;
26
26
import Relationship from '../../types/Relationship' ;
27
27
import FieldDocumentation from "../../types/Documentation/Field" ;
@@ -116,7 +116,7 @@ export default class MongooseAdapter implements Adapter<typeof MongooseAdapter>
116
116
( typeof offset !== "undefined" || typeof limit !== "undefined" ) ;
117
117
118
118
let primaryDocumentsPromise : Promise < Document | Document [ ] > ,
119
- includedResourcesPromise : Promise < Resource [ ] | undefined > ;
119
+ includedResourcesPromise : Promise < ReturnedResource [ ] | undefined > ;
120
120
121
121
const queryBuilder =
122
122
mode === "findOne" // ternary is a hack for TS compiler
@@ -216,19 +216,19 @@ export default class MongooseAdapter implements Adapter<typeof MongooseAdapter>
216
216
queryBuilder . populate ( pathParts [ 0 ] ) ;
217
217
} ) ;
218
218
219
- let includedResources : Resource [ ] = [ ] ;
219
+ let includedResources : ReturnedResource [ ] = [ ] ;
220
220
primaryDocumentsPromise = Promise . resolve ( queryBuilder . exec ( ) ) . then ( ( docOrDocs ) => {
221
221
includedResources =
222
222
objectValues (
223
223
Data . fromJSON ( docOrDocs ) // fromJSON to handle docOrDocs === null.
224
- . flatMap < Resource > ( ( doc ) => {
224
+ . flatMap < ReturnedResource > ( ( doc ) => {
225
225
return Data . of ( populatedPaths ) . flatMap ( ( path ) => {
226
226
// Handle case that doc[path], which should hold id(s) of the
227
227
// referenced documents, is undefined b/c the relationship isn't set.
228
228
return typeof doc [ path ] === 'undefined'
229
- ? Data . empty as Data < Resource >
229
+ ? Data . empty as Data < ReturnedResource >
230
230
: Data . fromJSON ( doc [ path ] ) . map ( docAtPath => {
231
- return this . docToResource ( docAtPath , fields ) ;
231
+ return this . docToResource ( docAtPath , fields ) as ReturnedResource ;
232
232
} ) ;
233
233
} ) ;
234
234
} )
@@ -237,7 +237,7 @@ export default class MongooseAdapter implements Adapter<typeof MongooseAdapter>
237
237
. reduce ( ( acc , resource ) => {
238
238
acc [ `${ resource . type } /${ resource . id } ` ] = resource ;
239
239
return acc ;
240
- } , { } as { [ id : string ] : Resource } )
240
+ } , { } as { [ id : string ] : ReturnedResource } )
241
241
) ;
242
242
243
243
return docOrDocs ;
0 commit comments