Use Range to make sure your reservations don't overlap in Postgres!

Опубликовано: 08 Октябрь 2024
на канале: Supabase
5,315
311

In apps involving start and end times, such as reservation or calendar apps, using range types in Postgres can bring many benefits, such as querying overlapping events or preventing overlaps under certain conditions.

Query ranges using the Supabase client library: https://supabase.com/docs/reference/j...

Range columns in Postgres represent the start and end of quantifiable data such as numbers, dates, or timestamps. Using ranges, you are introduced to advanced query operators along with exclude constraints that ensure no ranges overlap with each other under certain conditions, ensuring that reservations are protected at the database level.

CHAPTERS:
00:00 Intro
00:26: Range column introduction
01:45 Range type operations
02:37 Adding a constraint to prevent overlaps
04:00 Expanding the constraint to prevent overlaps only under certain condition
05:57 Outro

💻 Videos to watch next:
▶    • How to store and query JSON data in P...  
▶    • Make your queries 43,240x faster  
▶    • Self-host Maps with Protomaps and Sup...  

👇 Learn more about Supabase 👇

🕸 Website: https://supabase.com/
🏁 Get started: https://app.supabase.com/
📄 Docs: https://supabase.com/docs

🔔 Subscribe for more tutorials and feature updates from Supabase:    / @supabase  

📱 Connect with Us:
🐙 Github: https://www.github.com/supabase
💬 Discord: https://discord.supabase.com/
🐦 Twitter:   / supabase  
▶ Instagram (follow for memes):   / supabasecom  


ABOUT SUPABASE:
Supabase is the open source Firebase alternative. Supabase provides a full Postgres database for every project with pgvector, backups, realtime, and more. Add and manage email and password, passwordless, OAuth, and mobile logins to your project through a suite of identity providers and APIs.

Build in a weekend, scale to millions.

#Supabase #AppDevelopment #RealtimeApps #DeveloperTools