node-eventstore icon indicating copy to clipboard operation
node-eventstore copied to clipboard

Got error - The conditional request failed

Open jacklam718 opened this issue 7 years ago • 0 comments

Hi @adrai I'm using dynamodb. I can save events by the commit method but then I call commit for a exists stream then I got this error The conditional request failed

for example:

first time will be success

getEventStream (aggregateId: string){
  eventStore.getEventStream({
    aggregateId: '123',
    aggregate: 'Test',
    context: 'Test'
  }, (err, stream) => {
    if (err) return
    
    stream.addEvents([{
      type: 'ACCOUNT_CREATED',
      balance: 0,
    }]);
    stream.commit();
  });
}

second time will be fail - "The conditional request failed"

getEventStream (aggregateId: string){
  eventStore.getEventStream({
    aggregateId: '123',
    aggregate: 'Test',
    context: 'Test'
  }, (err, stream) => {
    if (err) return
    
    stream.addEvents([{
      type: 'DEPOSITED',
      amount: 200,
      balance: 200,
    }]);
    stream.commit();
  });
}

jacklam718 avatar Mar 10 '18 20:03 jacklam718