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 @@ -471,7 +471,7 @@ class Driver {
471
471
* @see {@link resultTransformers } for provided result transformers.
472
472
* @see https://github.com/neo4j/neo4j-javascript-driver/discussions/1052
473
473
*/
474
- async executeQuery < T > ( query : Query , parameters ?: any , config : QueryConfig < T > = { } ) : Promise < T > {
474
+ async executeQuery < T = EagerResult > ( query : Query , parameters ?: any , config : QueryConfig < T > = { } ) : Promise < T > {
475
475
const bookmarkManager = config . bookmarkManager === null ? undefined : ( config . bookmarkManager ?? this . queryBookmarkManager )
476
476
const resultTransformer = ( config . resultTransformer ?? resultTransformers . eagerResultTransformer ( ) ) as ResultTransformer < T >
477
477
const routingConfig : string = config . routing ?? routing . WRITERS
Original file line number Diff line number Diff line change @@ -342,6 +342,32 @@ describe('Driver', () => {
342
342
} , query , params )
343
343
} )
344
344
345
+ it ( 'should be able to destruct the result in records, keys and summary' , async ( ) => {
346
+ const query = 'Query'
347
+ const params = { }
348
+ const spiedExecute = jest . spyOn ( queryExecutor , 'execute' )
349
+ const expected : EagerResult = {
350
+ keys : [ 'a' ] ,
351
+ records : [ ] ,
352
+ summary : new ResultSummary ( query , params , { } , 5.0 )
353
+ }
354
+ spiedExecute . mockResolvedValue ( expected )
355
+
356
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
357
+ const { records, keys, summary } = await driver ! . executeQuery ( query , params )
358
+
359
+ expect ( records ) . toEqual ( expected . records )
360
+ expect ( keys ) . toEqual ( expected . keys )
361
+ expect ( summary ) . toEqual ( expected . summary )
362
+ expect ( spiedExecute ) . toBeCalledWith ( {
363
+ resultTransformer : resultTransformers . eagerResultTransformer ( ) ,
364
+ bookmarkManager : driver ?. queryBookmarkManager ,
365
+ routing : routing . WRITERS ,
366
+ database : undefined ,
367
+ impersonatedUser : undefined
368
+ } , query , params )
369
+ } )
370
+
345
371
it ( 'should be able get type-safe Records' , async ( ) => {
346
372
interface Person {
347
373
name : string
Original file line number Diff line number Diff line change @@ -471,7 +471,7 @@ class Driver {
471
471
* @see {@link resultTransformers } for provided result transformers.
472
472
* @see https://github.com/neo4j/neo4j-javascript-driver/discussions/1052
473
473
*/
474
- async executeQuery < T > ( query : Query , parameters ?: any , config : QueryConfig < T > = { } ) : Promise < T > {
474
+ async executeQuery < T = EagerResult > ( query : Query , parameters ?: any , config : QueryConfig < T > = { } ) : Promise < T > {
475
475
const bookmarkManager = config . bookmarkManager === null ? undefined : ( config . bookmarkManager ?? this . queryBookmarkManager )
476
476
const resultTransformer = ( config . resultTransformer ?? resultTransformers . eagerResultTransformer ( ) ) as ResultTransformer < T >
477
477
const routingConfig : string = config . routing ?? routing . WRITERS
You can’t perform that action at this time.
0 commit comments