olirice-read_once

v0.3.1Created a year agoBy olirice

read_once

A Supabase application for sending messages that can only be read once

Features:

  • messages can only be read one time
  • messages are not logged in PostgreSQL write-ahead-log (WAL)

Installation

pg_cron is a dependency of read_once. Dependency resolution is currently under development. In the near future it will not be necessary to manually create dependencies.

To expose the send_message and read_message functions over HTTP, install the extension in a schema that is on the search_path.

For example:

select dbdev.install('olirice-read_once');
create extension if not exists pg_cron;
create extension "olirice-read_once"
    schema public
    version '0.3.1';

HTTP API

Create a Message

curl -X POST https://<PROJECT_REF>.supabase.co/rest/v1/rpc/send_message \
    -H 'apiKey: <API_KEY>' \
    -H 'Content-Type: application/json'
    --data-raw '{"contents": "hello, dbdev!"}

# Returns: "2989156b-2356-4543-9d1b-19dfb8ec3268"

Read a Message

curl -X https://<PROJECT_REF>.supabase.co/rest/v1/rpc/read_message
    -H 'apiKey: <API_KEY>' \
    -H 'Content-Type: application/json' \
    --data-raw '{"id": "2989156b-2356-4543-9d1b-19dfb8ec3268"}

# Returns: "hello, dbdev!"

SQL API

Create a Message

-- Creates a new messages and returns its unique id
create or replace function send_message(
    contents text
)
    returns uuid

Read a Message

-- Read a message by its id
create or replace function read_message(
    id uuid
)
    returns text

Install

  1. Install the dbdev package manager
  2. Install the package:
select dbdev.install('olirice-read_once');
create extension "olirice-read_once"
    version '0.3.1';

Downloads

  • 2 all time downloads
  • 0 downloads in the last 30 days
  • 0 downloads in the last 90 days
  • 0 downloads in the last 180 days