Skip to content

how can I use this CronExpression ecto type ? #83

Description

@siddhant3030

hi, I have one question.

1:-
If I pass the cron_expression like this "* * * * ". It's saving as a struct in my database. Something like this ~e[/21 * * * * *].
But in order to consume from the frontend, I need to convert this struct to some other type.

So I tried this

  1. CronExpression.to_condition_list(availability.cron_expression) and this will give me something like this
[
  minute: [{:/, :*, 21}],
  hour: [:*],
  day: [:*],
  month: [:*],
  weekday: [:*],
  year: [:*]
]

but I'm not able to pass this in a JSON. In order to consume this, what data should I send? What should I do with struct?

Right now I'm getting this error when I'm trying to send after using the to_condition_list function.

** (Protocol.UndefinedError) protocol Jason.Encoder not implemented for {:minute, [{:/, :*, 21}]} of type Tuple, Jason.Encoder protocol must always be explicitly implemented.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions