tywalch / electrodb

A DynamoDB library to ease the use of modeling complex hierarchical relationships and implementing a Single Table Design while keeping your query code readable.
MIT License
956 stars 58 forks source link

Support `ConsistentRead` option #370

Open harlowk opened 3 months ago

harlowk commented 3 months ago

ConsistentRead Determines the read consistency model: If set to true, then the operation uses strongly consistent reads; otherwise, the operation uses eventually consistent reads.

Request to add consistentRead as an input option to gofor GET requests.

Expected:

    const { data: payment } = await PaymentSource.get({id:'xxx'}).go({
            consistentRead: true
    }); 

    // operation uses strongly consistent reads

I'll open an MR for this if I can find time.

tywalch commented 3 months ago

Yo! So there isn't a consistentRead option but you can use

entity.get({...})
    .go({ 
        params: {
            ConsistentRead: true
        }
    });

The params option is a sort of "escape hatch" to put properties directly onto the ddb parameters sent off 💪

tywalch commented 3 months ago

Oh, I'm dumb, I see now this is a request to add this option, not that it "doesn't work". I can add it 👍