I'm trying to query my items (which have fields of AWS DateTime of CreatedAt and UpdatedAt) for all within a certain date range. For example, the past 48 hours.
For example, using this schema:
type Note @model @searchable @auth(rules: [{ allow: owner }]) {
id: ID!
note: String
createdAt: AWSDateTime
I'm able to search for dates using, for example:
query {
searchNotes(filter:{createdAt: { matchPhrasePrefix: "2018-12-27"}}) {
items{
id
title
createdAt
}
}
}
Which returns all notes that match the UTC time with that string prefix.
From which, I have to sort myself using moment.diff(), or some other method.
I'm not sure there is a better/more efficient way of doing searching/filtering by dates and time using AppSync and GraphQl?
Thank you.