Getting Started and Console Check
Create a demonstration table, configure DDS access, and insert and read a row with your registered web app.
Overview
The JavaScript Relational SDK provides APIs for relational tables and views. It supports create, read, update, and delete (CRUD) operations, filters, JSON paths, ordering, pagination, joins, aggregates, remote procedure calls (RPCs), request controls, and structured errors.
This walkthrough uses a TODOS table. Run SQL as the project schema owner; run JavaScript in your registered application.
Before You Begin
Complete Installing and Configuring Oracle Backend with Supabase APIs and Adding Oracle Backend with Supabase APIs to Your Apps.
Have the following ready:
- A relational project and a registered web app.
- The app configuration copied from the Console.
- A SQL connection to the project-owning schema with permission to create a table.
- Permission to configure a Data Grant for the demonstration table.
The DDS example below uses unauthenticated application access. For an authenticated application, use the project’s authenticated Data Role and sign in before running the SDK examples.
Create a Table
Connect to the project schema and create the demonstration table:
CREATE TABLE todos (
id NUMBER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
title VARCHAR2(200) NOT NULL,
completed BOOLEAN DEFAULT FALSE NOT NULL,
priority NUMBER DEFAULT 1,
status VARCHAR2(20) DEFAULT 'open',
owner_id VARCHAR2(256),
created_at TIMESTAMP WITH TIME ZONE DEFAULT SYSTIMESTAMP,
completed_at TIMESTAMP WITH TIME ZONE
);
Oracle stores these unquoted identifiers in uppercase, including TODOS and ID. The SDK examples use lowercase request identifiers. The database generates ID when an insert omits it.
For SQL details, see CREATE TABLE.
Configure DDS Access
In the Console, open your project and select Database > Table Editor. Use Grants > Create grant to configure access to TODOS:
- Target the
TODOStable. - Select the project’s NoAuth Data Role.
- Under Actions, select SELECT and INSERT; leave UPDATE and DELETE cleared.
- For Column scope, select All columns.
- Permit all demonstration rows. Confirm that the SQL preview has no
WHEREpredicate.
Review the SQL preview before creating the grant. These permissions let unauthenticated application requests read and insert demonstration rows.
For the illustrated grant controls and a separate read-access test, follow Verify Application Data Access. Adapt that procedure’s target, actions, columns, and row predicate to this table.
See Database Access Control for role and predicate concepts.
Import and Initialize the SDK
Install the JavaScript Relational SDK:
npm install @fusabase/fusabase-relational
Create a client with your app’s configuration:
import { createClient } from '@fusabase/fusabase-relational';
const client = createClient('http://localhost:8080/ords/testuser/', {
schema: 'testuser',
app_name: 'DDSDemoWeb',
app_type: 'WEB',
app_id: '5FF51DB84D440682E0630300590AD54B',
objs_type: 'base',
backend_type: 'RELATIONAL',
project_id: '5FF51DB84D3E0682E0630300590AD54B',
storage_bucket: 'dds_demo',
auth_type: 'base',
auth_id: '5FF51DB84D4B0682E0630300590AD54B',
});
This example uses the documentation demo’s configuration. For another app, replace the URL and configuration values with those provided by the Console. Pass the ORDS URL as the first argument and the app configuration object as the second.
The client requires schema, app_type, app_id, project_id, objs_type, storage_bucket, auth_type, and auth_id. The app_name field is optional. A supplied backend_type for this client is "RELATIONAL".
Creating a client does not verify connectivity, the table definition, or DDS permissions.
Insert a Row
Insert a row and request its generated identifier. The unaliased projection returns uppercase property names for this table:
const inserted = await client
.from("todos")
.insert({
title: "Write documentation",
completed: false,
priority: 2,
})
.select("id,title,completed,priority");
if (inserted.error) {
throw inserted.error;
}
const todoId = inserted.data?.[0]?.ID;
if (todoId == null) {
throw new Error("The insert did not return a row identifier.");
}
Run the read example in the same scope so that todoId identifies the row you inserted. Handle thrown request failures in your application’s error handler.
Read it Back
Read that row by its identifier:
const result = await client
.from("todos")
.select("todo_id:id,todo_title:title,completed")
.eq("id", todoId);
if (result.error) {
throw result.error;
}
console.log(result.data);
The explicit projection aliases produce todo_id and todo_title. The unaliased completed column returns as COMPLETED. See Errors and Troubleshooting for response errors and thrown failures.
Check the Console
Return to Database > Table Editor, select Tables, and open TODOS. Confirm that the row with the returned identifier contains Write documentation and the values you inserted.
The Console shows data through the schema owner’s access. The SDK request checks the application’s DDS access. Seeing a row in the Console alone does not prove that the application can read it.
Continue with Row Operations.