Commit 5acead1 1 parent 1ec540c commit 5acead1 Copy full SHA for 5acead1
File tree 2 files changed +13
-5
lines changed
2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -741,6 +741,9 @@ export abstract class Builder
741
741
* @param definition - definition of return object as key value pair whereas value can be
742
742
* string selector or @see Selector
743
743
*
744
+ * @typeParam N - (optional) new target type of this cypher to hint the keys that you want
745
+ * to be sure of
746
+ *
744
747
* @example
745
748
* ```typescript
746
749
* // Selector Object:
@@ -752,7 +755,7 @@ export abstract class Builder
752
755
*
753
756
* ```typescript
754
757
* // String selector
755
- * q.returnObject({ user: 'person.name' });
758
+ * q.returnObject<{user: any}> ({ user: 'person.name' });
756
759
* ```
757
760
*
758
761
* ```typescript
@@ -763,10 +766,10 @@ export abstract class Builder
763
766
* ])
764
767
* ```
765
768
*/
766
- returnObject (
767
- definition : Many < Selectable < G > > ,
769
+ returnObject < N = unknown > (
770
+ definition : Many < Selectable < G , StringKeyOf < N > > > ,
768
771
) {
769
- return this . continueChainClause ( new ReturnObject ( definition ) ) ;
772
+ return this . continueChainClause ( new ReturnObject ( definition ) ) as any as Query < N > ;
770
773
}
771
774
772
775
/**
Original file line number Diff line number Diff line change @@ -2,7 +2,12 @@ import { Clause } from '../clause';
2
2
import { Many , isArray } from 'lodash' ;
3
3
import { Selector } from '../selector' ;
4
4
5
- export type Selectable < G > = Record < string , string | Selector < G > | Record < string , Selector < G > > > ;
5
+ /**
6
+ * @typeParam G - (optional) current graph model to gather data drom
7
+ * @typeParam T - (optional) Target type that defines the output
8
+ */
9
+ export type Selectable < G , T extends string = string >
10
+ = Record < T , string | Selector < G > | Record < T , Selector < G > > > ;
6
11
7
12
/**
8
13
* Clause to create an object formed RETURN
You can’t perform that action at this time.
0 commit comments