File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -132,13 +132,25 @@ export const toCursorUpdateRequest = (rule) => faulty((uow) => ({
132132} ) ) ;
133133
134134export const flushCursor = ( rule ) => ( s ) => {
135+ const {
136+ // By default group on a stringified version of the full key. If the key structure
137+ // differs in a users particular implementation or they want to group by something
138+ // else they can simply override this fn in their rule.
139+ cursorKeyFn = ( uow ) => `pk:${ uow . event . raw . new . pk } |sk:${ uow . event . raw . new . sk } ` ,
140+ } = rule ;
141+
135142 /* istanbul ignore else */
136143 if ( rule . toCursorUpdateRequest ) {
137144 return s
138145 // Compact explicitly on PK here since we want to capture just the last event per PK in this
139146 // invocation after the query split. This handles the case where multiple cursor events
140147 // ended up in a single lambda invocation.
141- . through ( compact ( { ...rule , compact : true } ) )
148+ . through ( compact ( {
149+ ...rule ,
150+ compact : {
151+ group : ( uow ) => cursorKeyFn ( uow ) ,
152+ } ,
153+ } ) )
142154 . map ( toCursorUpdateRequest ( rule ) )
143155 . through ( updateDynamoDB ( {
144156 ...rule ,
You can’t perform that action at this time.
0 commit comments