File tree Expand file tree Collapse file tree 3 files changed +28
-2
lines changed
neo4j-driver-deno/lib/core Expand file tree Collapse file tree 3 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -494,7 +494,7 @@ class Driver {
494
494
* @see {@link resultTransformers } for provided result transformers.
495
495
* @see https://github.com/neo4j/neo4j-javascript-driver/discussions/1052
496
496
*/
497
- async executeQuery < T > ( query : Query , parameters ?: any , config : QueryConfig < T > = { } ) : Promise < T > {
497
+ async executeQuery < T = EagerResult > ( query : Query , parameters ?: any , config : QueryConfig < T > = { } ) : Promise < T > {
498
498
const bookmarkManager = config . bookmarkManager === null ? undefined : ( config . bookmarkManager ?? this . queryBookmarkManager )
499
499
const resultTransformer = ( config . resultTransformer ?? resultTransformers . eagerResultTransformer ( ) ) as ResultTransformer < T >
500
500
const routingConfig : string = config . routing ?? routing . WRITERS
Original file line number Diff line number Diff line change @@ -379,6 +379,32 @@ describe('Driver', () => {
379
379
} , query , params )
380
380
} )
381
381
382
+ it ( 'should be able to destruct the result in records, keys and summary' , async ( ) => {
383
+ const query = 'Query'
384
+ const params = { }
385
+ const spiedExecute = jest . spyOn ( queryExecutor , 'execute' )
386
+ const expected : EagerResult = {
387
+ keys : [ 'a' ] ,
388
+ records : [ ] ,
389
+ summary : new ResultSummary ( query , params , { } , 5.0 )
390
+ }
391
+ spiedExecute . mockResolvedValue ( expected )
392
+
393
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
394
+ const { records, keys, summary } = await driver ! . executeQuery ( query , params )
395
+
396
+ expect ( records ) . toEqual ( expected . records )
397
+ expect ( keys ) . toEqual ( expected . keys )
398
+ expect ( summary ) . toEqual ( expected . summary )
399
+ expect ( spiedExecute ) . toBeCalledWith ( {
400
+ resultTransformer : resultTransformers . eagerResultTransformer ( ) ,
401
+ bookmarkManager : driver ?. queryBookmarkManager ,
402
+ routing : routing . WRITERS ,
403
+ database : undefined ,
404
+ impersonatedUser : undefined
405
+ } , query , params )
406
+ } )
407
+
382
408
it ( 'should be able get type-safe Records' , async ( ) => {
383
409
interface Person {
384
410
name : string
Original file line number Diff line number Diff line change @@ -494,7 +494,7 @@ class Driver {
494
494
* @see {@link resultTransformers } for provided result transformers.
495
495
* @see https://github.com/neo4j/neo4j-javascript-driver/discussions/1052
496
496
*/
497
- async executeQuery < T > ( query : Query , parameters ?: any , config : QueryConfig < T > = { } ) : Promise < T > {
497
+ async executeQuery < T = EagerResult > ( query : Query , parameters ?: any , config : QueryConfig < T > = { } ) : Promise < T > {
498
498
const bookmarkManager = config . bookmarkManager === null ? undefined : ( config . bookmarkManager ?? this . queryBookmarkManager )
499
499
const resultTransformer = ( config . resultTransformer ?? resultTransformers . eagerResultTransformer ( ) ) as ResultTransformer < T >
500
500
const routingConfig : string = config . routing ?? routing . WRITERS
You can’t perform that action at this time.
0 commit comments