Skip to content

Date field formatting and orderBy. #112

@thruflo

Description

@thruflo

I have an ElectricCollection which loads tasks that have an inserted_at date field.

I'm parsing this when I sync the data:

const parser = {
  timestamp: (date: string) => new Date(date)
}

This is working, I see the date object in the collection data.

When I query it:

const { data } = useLiveQuery(query => (
    query
      .from({ taskCollection })
      .select('@id', '@title', '@inserted_at')
      .orderBy({'@inserted_at': 'desc'})
      .keyBy('@id')
  ))
  1. I get the string version of the field back from the query
  2. the orderBy doesn't work

The latter is confusing -- because I believe it was working and then stopped working. OrderBy works if I sort on another field. But not for inserted_at.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions