Postgres Foreign Data Wrapper for Clerk.com API

Related tags

Database clerk_fdw
Overview

Pre-requisites

  • Postgres-15
  • Rust
  • pgrx

Getting Started

To run the program locally, clone the repository git clone https://github.com/tembo-io/clerk_fdw.git

Run the program using the command cargo pgrx run

Create the wrapper extension create extension clerk_fdw;

Create the foreign data wrapper:

create foreign data wrapper clerk_wrapper
  handler clerk_fdw_handler
  validator clerk_fdw_validator;

Connect to clerk using your credentials:


create server my_clerk_server
  foreign data wrapper clerk_wrapper
  options (
    api_key '<clerk secret Key>')

Create Foreign Table:


create foreign table clerk (
  id text,
  first_name text,
  email text,
  last_name text,
  gender text,
  created_at bigint,
  last_sign_in_at bigint,
  phone_numbers bigint,
  username text,
  updated_at bigint,
  organization text,
  role text
  )
  server my_clerk_server;

This wrapper currently only supports displaying the name and email. Note: We will soon support being able to request more fields like orgranizations, roles etc.

Query from the Foreign Table: select * from clerk

SQL queries for most common tasks

To display all organizations SELECT DISTINCT unnest(string_to_array(organization, ',')) AS unique_organization FROM clerk;

To list all Users SELECT id, first_name, last_name, email FROM clerk;

To list all Users of an Organization with Role

WITH org_roles AS (
  SELECT
    id,
    first_name,
    last_name,
    UNNEST(STRING_TO_ARRAY(organization, ',')) AS org,
    UNNEST(STRING_TO_ARRAY(role, ',')) AS org_role
  FROM clerk
)
SELECT
  id,
  first_name,
  last_name,
  org_role AS specific_role
FROM org_roles
WHERE org = 'OrgName';

You might also like...
A Pub/Sub library for Rust backed by Postgres

Unisub Unisub is a Pub/Sub library for Rust, using Postgres as the backend. It offers a convenient way to publish and subscribe to messages across dif

Rust library and daemon for easily starting postgres databases per-test without Docker

pgtemp pgtemp is a Rust library and cli tool that allows you to easily create temporary PostgreSQL servers for testing without using Docker. The pgtem

An API Wrapper for https://paste.myst.rs written in rust
An API Wrapper for https://paste.myst.rs written in rust

PasteMyst.RS pastemyst-rs is an api wrapper for pastemyst written in Rust. ⚠ This package is under development ⚠ Sample usage To get a paste from past

a tokio-enabled data store for triple data

terminusdb-store, a tokio-enabled data store for triple data Overview This library implements a way to store triple data - data that consists of a sub

A Modern Real-Time Data Processing & Analytics DBMS with Cloud-Native Architecture, built to make the Data Cloud easy
A Modern Real-Time Data Processing & Analytics DBMS with Cloud-Native Architecture, built to make the Data Cloud easy

A Modern Real-Time Data Processing & Analytics DBMS with Cloud-Native Architecture, built to make the Data Cloud easy

Implements the packet parser for Gran Turismo 7 telemetry data, allowing a developer to retrieve data from a running game.

gran-turismo-query Implements the packet parser for Gran Turismo 7 telemetry data, allowing a developer to retrieve data from a running game. Features

Plugin for macro-, mini-quad (quads) to save data in simple local storage using Web Storage API in WASM and local file on a native platforms.

quad-storage This is the crate to save data in persistent local storage in miniquad/macroquad environment. In WASM the data persists even if tab or br

rust wrapper for rocksdb

rust-rocksdb Requirements Clang and LLVM Contributing Feedback and pull requests welcome! If a particular feature of RocksDB is important to you, plea

UnQLite wrapper 1.0 is avaliable for Rust

unqlite A high-level UnQLite database engine wrapper. NOTE: Some of the documents is stolen from UnQLite Official Website. What is UnQLite? UnQLite is

Comments
  • Organization limit

    Organization limit

    Limit on users_get_organization_memberships and list_organization_memberships. Might need to update this when we have multiple people being part of multiple organizations.

    enhancement 
    opened by Jayko001 0
Releases(v0.1.3)
  • v0.1.3(Aug 28, 2023)

    What's Changed

    • hopeful bug fix by @Jayko001 in https://github.com/tembo-io/clerk_fdw/pull/9
    • Update Cargo.toml by @ChuckHend in https://github.com/tembo-io/clerk_fdw/pull/10

    New Contributors

    • @ChuckHend made their first contribution in https://github.com/tembo-io/clerk_fdw/pull/10

    Full Changelog: https://github.com/tembo-io/clerk_fdw/compare/v0.1.2...v0.1.3

    Source code(tar.gz)
    Source code(zip)
  • v0.1.2(Aug 28, 2023)

    What's Changed

    • updated code to better reflect wrapper guidlines by @Jayko001 in https://github.com/tembo-io/clerk_fdw/pull/7

    Full Changelog: https://github.com/tembo-io/clerk_fdw/compare/v0.1.1...v0.1.2

    Source code(tar.gz)
    Source code(zip)
  • v0.1.0(Aug 24, 2023)

    What's Changed

    • removed limit of 10 on getUserList by @Jayko001 in https://github.com/tembo-io/clerk_fdw/pull/4

    Full Changelog: https://github.com/tembo-io/clerk_fdw/compare/v0.0.0...v0.1.0

    Source code(tar.gz)
    Source code(zip)
  • v0.0.0(Aug 22, 2023)

    Initial release

    What's Changed

    • v.0.1 of workflow by @Jayko001 in https://github.com/tembo-io/clerk_fdw/pull/1

    New Contributors

    • @Jayko001 made their first contribution in https://github.com/tembo-io/clerk_fdw/pull/1

    Full Changelog: https://github.com/tembo-io/clerk_fdw/commits/v0.0.0

    Source code(tar.gz)
    Source code(zip)
Owner
Tembo
Tembo
postgres-ical - a PostgreSQL extension that adds features related to parsing RFC-5545 « iCalendar » data from within a PostgreSQL database

postgres-ical - a PostgreSQL extension that adds features related to parsing RFC-5545 « iCalendar » data from within a PostgreSQL database

Edgar Onghena 1 Feb 23, 2022
Scalable and fast data store optimised for time series data such as financial data, events, metrics for real time analysis

OnTimeDB Scalable and fast data store optimised for time series data such as financial data, events, metrics for real time analysis OnTimeDB is a time

Stuart 2 Apr 5, 2022
Manage Redshift/Postgres privileges in GitOps style written in Rust

grant-rs An open-source project that aims to manage Postgres/Redshift database roles and privileges in GitOps style, written in Rust. Home | Documenta

Duyet Le 13 Nov 23, 2022
cogo rust coroutine database driver (Mysql,Postgres,Sqlite)

cdbc Coroutine Database driver Connectivity.based on cogo High concurrency,based on coroutine No Future<'q,Output=*>,No async fn, No .await , no Poll*

co-rs 10 Nov 13, 2022
Making Postgres and Elasticsearch work together like it's 2021

Making Postgres and Elasticsearch work together like it's 2021 Readme ZomboDB brings powerful text-search and analytics features to Postgres by using

ZomboDB 4.2k Jan 2, 2023
Distributed, version controlled, SQL database with cryptographically verifiable storage, queries and results. Think git for postgres.

SDB - SignatureDB Distributed, version controlled, SQL database with cryptographically verifiable storage, queries and results. Think git for postgres

Fremantle Industries 5 Apr 26, 2022
rust-postgres support library for the r2d2 connection pool

r2d2-postgres Documentation rust-postgres support library for the r2d2 connection pool. Example use std::thread; use r2d2_postgres::{postgres::NoTls,

Steven Fackler 128 Dec 26, 2022
An easy-to-use, zero-downtime schema migration tool for Postgres

Reshape is an easy-to-use, zero-downtime schema migration tool for Postgres. It automatically handles complex migrations that would normally require downtime or manual multi-step changes.

Fabian Lindfors 1.4k Dec 25, 2022
Command-line tool to make Rust source code entities from Postgres tables.

pg2rs Command-line tool to make Rust source code entities from Postgres tables. Generates: enums structs which can be then used like mod structs; use

Stanislav 10 May 20, 2022
The simplest implementation of LLM-backed vector search on Postgres.

pg_vectorize under development The simplest implementation of LLM-backed vector search on Postgres. -- initialize an existing table select vectorize.i

Tembo 5 Jul 25, 2023