File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ export const apoc = {
69
69
} ,
70
70
coll : {
71
71
flatten : fn1 ( 'apoc.coll.flatten' ) ,
72
+ indexOf : fn ( 'apoc.coll.indexOf' ) ,
72
73
} ,
73
74
convert : {
74
75
/** Converts Neo4j node to object/map of the node's properties */
Original file line number Diff line number Diff line change @@ -3,13 +3,14 @@ import { identity } from 'rxjs';
3
3
import {
4
4
getDbSortTransformer ,
5
5
ID ,
6
+ MadeEnum ,
6
7
Order ,
7
8
PaginatedListType ,
8
9
PaginationInput ,
9
10
Resource ,
10
11
ResourceShape ,
11
12
} from '~/common' ;
12
- import { collect } from './cypher-functions' ;
13
+ import { apoc , collect } from './cypher-functions' ;
13
14
import { ACTIVE } from './matching' ;
14
15
15
16
/**
@@ -97,7 +98,7 @@ export const sorting =
97
98
return query . comment `sorting(${ sort } )`
98
99
. subQuery ( '*' , matcher )
99
100
. with ( '*' )
100
- . orderBy ( sortTransformer ( 'sortValue' ) , order ) ;
101
+ . orderBy ( ` ${ sortTransformer ( 'sortValue' ) } ` , order ) ;
101
102
} ;
102
103
103
104
const matchPropSort = ( prop : string ) => ( query : Query ) =>
@@ -112,6 +113,14 @@ const matchPropSort = (prop: string) => (query: Query) =>
112
113
const matchBasePropSort = ( prop : string ) => ( query : Query ) =>
113
114
query . return ( `node.${ prop } as sortValue` ) ;
114
115
116
+ export const sortingForEnumIndex =
117
+ < T extends string > ( theEnum : MadeEnum < T > ) =>
118
+ ( variable : string ) =>
119
+ apoc . coll . indexOf (
120
+ [ ...theEnum . values ] . map ( ( v ) => `"${ v } "` ) ,
121
+ variable ,
122
+ ) ;
123
+
115
124
export const whereNotDeletedInChangeset = ( changeset ?: ID ) => ( query : Query ) =>
116
125
changeset
117
126
? query . raw (
You can’t perform that action at this time.
0 commit comments