惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Hugging Face - Blog
Hugging Face - Blog
C
Cybersecurity and Infrastructure Security Agency CISA
G
Google Developers Blog
The Cloudflare Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
The GitHub Blog
The GitHub Blog
TaoSecurity Blog
TaoSecurity Blog
V
Visual Studio Blog
D
DataBreaches.Net
人人都是产品经理
人人都是产品经理
博客园 - Franky
S
Security @ Cisco Blogs
Hacker News - Newest:
Hacker News - Newest: "LLM"
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
C
Cyber Attacks, Cyber Crime and Cyber Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
H
Hackread – Cybersecurity News, Data Breaches, AI and More
腾讯CDC
T
Troy Hunt's Blog
B
Blog RSS Feed
A
About on SuperTechFans
IT之家
IT之家
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
J
Java Code Geeks
S
Securelist
T
Threatpost
SecWiki News
SecWiki News
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Y
Y Combinator Blog
Blog — PlanetScale
Blog — PlanetScale
aimingoo的专栏
aimingoo的专栏
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Forbes - Security
Forbes - Security
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
D
Docker
N
News and Events Feed by Topic
Schneier on Security
Schneier on Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
月光博客
月光博客
C
CXSECURITY Database RSS Feed - CXSecurity.com
罗磊的独立博客
H
Hacker News: Front Page
N
News and Events Feed by Topic
N
Netflix TechBlog - Medium
AWS News Blog
AWS News Blog
P
Privacy International News Feed
Scott Helme
Scott Helme
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
V
Vulnerabilities – Threatpost
The Register - Security
The Register - Security

Supabase Blog

AI Agents Know About Supabase. They Don't Always Use It Right. Custom OIDC Providers for Supabase Auth 100,000 GitHub stars Supabase docs over SSH Navigating Regional Network Blocks Supabase Joins the Stripe Projects Developer Preview Log Drains: Now available on Pro Supabase Storage: major performance, security, and reliability updates Supabase incident on February 12, 2026 Hydra joins Supabase X / Twitter OAuth 2.0 is now available for Supabase Auth BKND joins Supabase Supabase is now an official Claude connector Supabase PrivateLink is now available Introducing: Postgres Best Practices When to use Read Replicas vs. bigger compute Introducing TRAE SOLO integration with Supabase Supabase Security Retro: 2025 Sync Stripe Data to Your Supabase Database in One Click Building ChatGPT Apps with Supabase Edge Functions and mcp-use Own Your Observability: Supabase Metrics API Introducing iceberg-js: A JavaScript Client for Apache Iceberg Introducing Supabase for Platforms Adding Async Streaming to Postgres Foreign Data Wrappers Build "Sign in with Your App" using Supabase Auth Introducing Seven New Email Templates for Supabase Auth The new Supabase power for Kiro Introducing Supabase ETL Introducing Analytics Buckets Introducing Vector Buckets Snap, Inc. Launches Snap Cloud, Powered by Supabase Triplit joins Supabase Supabase Series E 1000 Y Combinator Founders Choose Supabase gm 👋 web3, welcome aboard to Sign in with Web3 (Solana, Ethereum) Announcing the Supabase Remote MCP Server Enterprise speed, enterprise standards with Bolt Cloud + Supabase PostgREST 13 Lovable Cloud + Supabase: The Default Platform for AI Builders Processing large jobs with Edge Functions, Cron, and Queues Defense in Depth for MCP Servers OrioleDB Patent: now freely available to the Postgres community Supabase Launch Week 15 Hackathon Winner Announcement The Vibe Coder's Guide to Supabase Environments Testing for Vibe Coders: From Zero to Production Confidence The Vibe Coding Master Checklist Vibe Coding: Best Practices for Prompting Supabase Auth: Build vs. Buy Top 10 Launches of Launch Week 15 Supabase Launch Week 15 Hackathon Storage: 10x Larger Uploads, 3x Cheaper Cached Egress, and 2x Egress Quota Persistent Storage and 97% Faster Cold Starts for Edge Functions Algolia Connector for Supabase New Observability Features in Supabase Improved Security Controls and A New Home for Security Introducing Branching 2.0 Stripe-To-Postgres Sync Engine as standalone Library Supabase Analytics Buckets with Iceberg Support Create a Supabase backend using Figma Make Introducing JWT Signing Keys Supabase UI: Platform Kit Build a Personalized AI Assistant with Postgres Announcing Multigres: Vitess for Postgres Building on open table formats Open Data Standards: Postgres, OTel, and Iceberg Simplifying back-end complexity with Supabase Data APIs PostgreSQL Event Triggers without superuser access Top 10 Launches of Launch Week 14 Supabase MCP Server Data API Routes to Nearest Read Replica Declarative Schemas for Simpler Database Management Realtime: Broadcast from Database Keeping Tabs on What's New in Supabase Studio Edge Functions: Deploy from the Dashboard + Deno 2.1 Automatic Embeddings in Postgres Introducing the Supabase UI Library Supabase Auth: Bring Your Own Clerk Postgres Language Server: Initial Release Migrating from Fauna to Supabase Migrating from the MongoDB Data API to Supabase Dedicated Poolers Postgres as a Graph Database: (Ab)using pgRouting AI Hackathon at Y Combinator Supabase Launch Week 13 Hackathon Winners How to Hack the Base! Running Durable Workflows in Postgres using DBOS database.build v2: Bring-your-own-LLM Restore to a New Project Hack the Base! with Supabase Top 10 Launches of Launch Week 13 Supabase Queues High Performance Disk Supabase Cron Supabase CLI v2: Config as Code Supabase Edge Functions: Introducing Background Tasks, Ephemeral Storage, and WebSockets Supabase AI Assistant v2 OrioleDB Public Alpha Executing Dynamic JavaScript Code on Supabase with Edge Functions ClickHouse Partnership, improved Postgres Replication, and Disk Management Live Share: Connect to in-browser PGlite with any Postgres client
Calendars in Postgres using Foreign Data Wrappers
Bo Lu · 2024-12-20 · via Supabase Blog

Calendars in Postgres using Foreign Data Wrappers

Today we're releasing Foreign Data Wrappers for Cal.com so that you can create event bookings directly from Postgres.

This is especially useful for signup forms where you create an event in your database and schedule an event simultaneously: now you can do all this in a single Postgres transaction.

Cal.com is an open-source scheduling platform that allows individuals and businesses to book and manage appointments. It is designed to work with a variety of use cases, from personal calendars to enterprise-grade scheduling systems. They have a great developer toolkit.

Creating event bookings with Postgres#

Cal.com offers various scheduling features. One of the most common scenarios for developers is creating a new event in a calendar (for example, after someone has purchased a flight).

Let's use your Supabase database to create an event in Cal.com, using Postgres Foreign Data Wrappers.

Set up a Cal.com account#

Set up a Supabase account#

Create Wasm wrapper and a foreign server#

Visit Supabase SQL Editor, use below SQL to create the Wasm foreign data wrapper:


_10

create foreign data wrapper wasm_wrapper

_10

handler wasm_fdw_handler

_10

validator wasm_fdw_validator;


And then create a foreign server for Cal.com connection with your API Key:


_10

create server cal_server

_10

foreign data wrapper wasm_wrapper

_10

options (

_10

fdw_package_url 'https://github.com/supabase/wrappers/releases/download/wasm_cal_fdw_v0.1.0/cal_fdw.wasm',

_10

fdw_package_name 'supabase:cal-fdw',

_10

fdw_package_version '0.1.0',

_10

fdw_package_checksum '4afe4fac8c51f2caa1de8483b3817d2cec3a14cd8a65a3942c8b4ff6c430f08a',

_10

api_key '<your Cal.com API key>'

_10

);


Set up foreign tables#

Now let's setup the foreign tables. First of all, create a dedicate schema for the foreign tables:


_10

create schema if not exists cal;


And then create a foreign table for Event Types:


_10

create foreign table cal.event_types (

_10

attrs jsonb

_10

)

_10

server cal_server

_10

options (

_10

object 'event-types'

_10

);


And another foreign table for Bookings:


_10

create foreign table cal.bookings (

_10

attrs jsonb

_10

)

_10

server cal_server

_10

options (

_10

object 'bookings',

_10

rowid_column 'attrs'

_10

);


Note the rowid_column option which is required to insert data into cal.bookings table, we will see it later.

Query Event Types and Bookings from Cal.com#

Great, now we are all set, it's time to query some juicy data from Cal.com! Let's start query from Event Types first:


_10

-- extract event types

_10

select

_10

etg->'profile'->>'name' as profile,

_10

et->>'id' as id,

_10

et->>'title' as title

_10

from cal.event_types t

_10

cross join json_array_elements((attrs->'eventTypeGroups')::json) etg

_10

cross join json_array_elements((etg->'eventTypes')::json) et;


Note all the scheduling information returned from Cal.com API are stored in the JSON column attrs , from which we can extract any fields of that object. For example, we can extract id, title, name and etc., from Bookings object:


_10

-- extract bookings

_10

select

_10

bk->>'id' as id,

_10

bk->>'title' as title,

_10

bk->'responses'->>'name' as name,

_10

bk->>'startTime' as start_time

_10

from cal.bookings t

_10

cross join json_array_elements((attrs->'bookings')::json) bk;


Oops, it looks like we haven't booked any meetings with anybody yet. Now it's the fun part, let's make a booking on Cal.com from Supabase!

Make a bookings on Cal.com from Supabase#

To make a booking directly from Postgres, all we need to do is to insert a record to cal.bookings foreign table, with the booking details in JSON format. For example,


_13

-- make a 15 minutes meeting with Elon Musk

_13

insert into cal.bookings(attrs)

_13

values (

_13

'{

_13

"start": "2025-01-01T23:30:00.000Z",

_13

"eventTypeId": 1398027,

_13

"attendee": {

_13

"name": "Elon Musk",

_13

"email": "elon.musk@x.com",

_13

"timeZone": "America/New_York"

_13

}

_13

}'::jsonb

_13

);


Here you can see we made a 15 minutes meeting booking with Elon, just to give him a happy new year greeting 😄. Note the eventTypeId , “1398027”, is our 15 Min Meeting event type ID, you can find yours by querying the cal.event_types foreign table using above example SQL.

After inserting the booking record, we can verify it appears on our upcoming list in Cal.com.

When we query cal.bookings again using the previous SQL, we can see our new booking record is in the results as well.

That wraps up our tutorial! We've covered how to interact with Cal.com in Supabase using foreign wrapper and tables. For more information about available objects and fields, refer to the Cal.com API v2 reference and the Wrappers Cal.com Wasm Wrapper documentation.

The Cal.com FDW is built with Wrappers, a framework for Postgres Foreign Data Wrappers (FDW). Our latest release supports Wasm (WebAssembly) to simplify development for API-based services.

We've built a variety of wrappers available on fdw.dev, ranging from popular tools like Stripe and Notion to databases like ClickHouse and BigQuery. Check out the full catalog and get started with Supabase today:

database.new