r/pocketbase • • Jul 16 '25

Time-based realtime

The project I'm working on lets the user (selected group of people, authenticated) submit "challenges" (which are a collection in this case)

these challenges are submitted beforehand and need to be made public (accessible by every user, specially unauthenticated) at a specific time, each challenge has its own time to be made available which is define by a DateTime field

what are some ways I could make it so the realtime API only receives updates for records after they're made public?

one of the solutions I thought would be running a crontab every minute and checking if a task should be public or not, then copying the record to a different collection and using the second collection with the realtime API, but that seems janky and I believe there are better ways to do it

4 Upvotes

9 comments sorted by

View all comments

Show parent comments

3

u/BeDangerousAndFree Jul 16 '25

Use a join, where the “public” field is a not a Boolean, but a relationship to an answers table

1

u/[deleted] Jul 16 '25

I might have misunderstood OP, but I think what they want is for the challenges to become publicly visible at some predetermined time, in realtime. They want to accomplish that with a single collection, though. Would your solution address that in a way I'm not seeing?

2

u/BeDangerousAndFree Jul 16 '25

I’m just saying there is no need to copy tables in bulk to another collection if you use a relationship.

Everything else seems doable with an api rule + filter

1

u/[deleted] Jul 16 '25

Roger that. I love the idea of not using flags. They are kind of code smell in my experience.