Cal.com
Cal.com is an open source scheduling platform.
The Cal Wrapper is a WebAssembly(Wasm) foreign data wrapper which allows you to read data from your Cal.com account for use within your Postgres database.
Warning
Restoring a logical backup of a database with a materialized view using a foreign table can fail. For this reason, either do not use foreign tables in materialized views or use them in databases with physical backups enabled.
Supported Data Types
Postgres Data Type | Cal.com Data Type |
---|---|
boolean | Boolean |
bigint | Number |
double precision | Number |
text | String |
jsonb | Json |
The Cal.com API uses JSON formatted data, please refer to Cal.com API docs for more details.
Note
This foreign data wrapper only supports Cal.com API v2.
Available Versions
Version | Wasm Package URL | Checksum |
---|---|---|
0.1.0 | https://github.com/supabase/wrappers/releases/download/wasm_cal_fdw_v0.1.0/cal_fdw.wasm |
4b8661caae0e4f7b5a1480ea297cf5681101320712cde914104b82f2b0954003 |
Preparation
Before you get started, make sure the wrappers
extension is installed on your database:
1 |
|
and then create the Wasm foreign data wrapper:
1 2 3 |
|
Secure your credentials (optional)
By default, Postgres stores FDW credentials inside pg_catalog.pg_foreign_server
in plain text. Anyone with access to this table will be able to view these credentials. Wrappers is designed to work with Vault, which provides an additional level of security for storing credentials. We recommend using Vault to store your credentials.
1 2 3 4 5 6 7 |
|
Connecting to Cal.com
We need to provide Postgres with the credentials to access Cal.com and any additional options. We can do this using the create server
command:
1 2 3 4 5 6 7 8 9 10 |
|
1 2 3 4 5 6 7 8 9 10 |
|
Note the fdw_package_*
options are required, which specify the Wasm package metadata. You can get the available package version list from above.
Create a schema
We recommend creating a schema to hold all the foreign tables:
1 |
|
Creating Foreign Tables
The Cal.com Wrapper supports data reads from below objects in Cal.com.
Integration | Select | Insert | Update | Delete | Truncate |
---|---|---|---|---|---|
My Profile | ✅ | ❌ | ❌ | ❌ | ❌ |
Event Types | ✅ | ❌ | ❌ | ❌ | ❌ |
Bookings | ✅ | ❌ | ❌ | ❌ | ❌ |
Calendars | ✅ | ❌ | ❌ | ❌ | ❌ |
Schedules | ✅ | ❌ | ❌ | ❌ | ❌ |
Conferencing | ✅ | ❌ | ❌ | ❌ | ❌ |
For example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
|
Note
- All the supported columns are listed above, other columns are not allowd.
- The
attrs
is a special column which stores all the object attributes in JSON format, you can extract any attributes needed from it. See more examples below.
Foreign table options
The full list of foreign table options are below:
object
- Object name in Cal.com, required.
Supported objects are listed below:
Object name |
---|
my_profile |
event-types |
bookings |
calendars |
schedules |
conferencing |
Query Pushdown Support
This FDW doesn't support query pushdown.
Examples
Below are some examples on how to use Cal.com foreign tables.
Basic example
This example will create a "foreign table" inside your Postgres database and query its data. First, we can create a schema to hold all the Cal.com foreign tables.
1 |
|
Then create the foreign table and query it, for example:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
attrs
is a special column which stores all the object attributes in JSON format, you can extract any attributes needed from it. See more examples below.
Query JSON attributes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
|