Giter Club home page Giter Club logo

Comments (2)

M1chaelTran avatar M1chaelTran commented on May 27, 2024 1

hi @endymion00

It funny that you ask because we have to do the same thing just last week.
I spend a whole day to figure out how to do this... so hoped you didn't have to go through the same ordeal.

Yes, dynamoDB stores data type as string...
but they have RangeKey that works with dates, with the exception that the date string are stored in UTC.

so what you need to do is set the createdAt or updatedAt as the rangeKey
on insertion, you'll need to set the createdAt as part of the insertion (recommended to use momentjs moment.utc().toISOString())

then on query, you'll need to do something along the line of:

OrderTable.scan().loadAll()
        .filterExpression('CreatedAt BETWEEN :fromDate AND :toDate')
        .expressionAttributeValues({':fromDate': fromDate, ':toDate': toDate})
        .projectionExpression('OrderName, OrderId, OrderAddress') \\ optional

from dynogels.

endymion00 avatar endymion00 commented on May 27, 2024

hey @M1chaelTran,

Thank you very much for help :)
I've started the migration from number dates to ISO string dates since it is more human readable for application data troubleshooting and also to avoid transformations when sending and receiving dates from an API (we use API Gateway over dynamoDB)

And yes, moment is the way to go. I feel very confident by using this module in all my node projects. In this case with one single of line of code it is possible to migrate from number dates to string dates easily.

from dynogels.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.