@@ -36,12 +36,14 @@ export type UpdatePropertyOptions<
36
36
id : ID ;
37
37
} ,
38
38
Key extends keyof DbChanges < TObject > & string ,
39
+ StatsVar extends string = 'stats' ,
39
40
> = DeactivatePropertyOptions < TResourceStatic , TObject , Key > &
40
41
CreatePropertyOptions < TResourceStatic , TObject , Key > & {
41
42
/**
42
43
* The property is permanent after this given duration.
43
44
*/
44
45
permanentAfter ?: Variable | DurationIn ;
46
+ outputStatsVar ?: StatsVar ;
45
47
} ;
46
48
47
49
export interface PropUpdateStat {
@@ -62,11 +64,16 @@ export const updateProperty =
62
64
id : ID ;
63
65
} ,
64
66
Key extends keyof DbChanges < TObject > & string ,
67
+ const StatsVar extends string = 'stats' ,
65
68
> (
66
- options : UpdatePropertyOptions < TResourceStatic , TObject , Key > ,
69
+ options : UpdatePropertyOptions < TResourceStatic , TObject , Key , StatsVar > ,
67
70
) =>
68
- < R > ( query : Query < R > ) : Query < { stats : PropUpdateStat } > => {
69
- const { permanentAfter, ...resolved } = {
71
+ < R > ( query : Query < R > ) : Query < { [ _ in StatsVar ] : PropUpdateStat } > => {
72
+ const {
73
+ permanentAfter,
74
+ outputStatsVar = 'stats' ,
75
+ ...resolved
76
+ } = {
70
77
...options ,
71
78
nodeName : options . nodeName ?? 'node' ,
72
79
value :
@@ -93,12 +100,12 @@ export const updateProperty =
93
100
query
94
101
. apply ( deactivateProperty < TResourceStatic , TObject , Key > ( resolved ) )
95
102
. apply ( createProperty < TResourceStatic , TObject , Key > ( resolved ) )
96
- . return < { stats : PropUpdateStat } > ( [
103
+ . return < { [ _ in StatsVar ] : PropUpdateStat } > ( [
97
104
exp ( {
98
105
method : '"new entry"' ,
99
106
deactivated : 'numPropsDeactivated' ,
100
107
created : 'numPropsCreated' ,
101
- } ) . as ( 'stats' ) ,
108
+ } ) . as ( outputStatsVar ) ,
102
109
] ) ;
103
110
104
111
if ( ! permanentAfter ) {
@@ -111,11 +118,11 @@ export const updateProperty =
111
118
'existingProp.value' : value . toString ( ) ,
112
119
'existingProp.modifiedAt' : now . toString ( ) ,
113
120
} )
114
- . return < { stats : PropUpdateStat } > ( [
121
+ . return < { [ _ in StatsVar ] : PropUpdateStat } > ( [
115
122
exp ( {
116
123
method : '"inline replace"' ,
117
124
updated : 1 ,
118
- } ) . as ( 'stats' ) ,
125
+ } ) . as ( outputStatsVar ) ,
119
126
] ) ;
120
127
121
128
return query
0 commit comments