Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@supabase/postgrest-js

Package Overview
Dependencies
Maintainers
3
Versions
138
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@supabase/postgrest-js

Isomorphic PostgREST client

  • 0.23.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created

What is @supabase/postgrest-js?

@supabase/postgrest-js is a JavaScript client library for interacting with PostgREST APIs. It allows you to perform CRUD operations, filter data, and manage real-time subscriptions with ease. This package is particularly useful for developers working with Supabase, a backend-as-a-service platform that provides a PostgREST API for interacting with PostgreSQL databases.

What are @supabase/postgrest-js's main functionalities?

CRUD Operations

This feature allows you to perform basic CRUD (Create, Read, Update, Delete) operations on your database tables. The code sample demonstrates how to insert a new record, read records, update a record, and delete a record from a 'users' table.

const { createClient } = require('@supabase/postgrest-js');

const client = createClient('https://your-project.supabase.co', 'public-anon-key');

// Create a new record
client.from('users').insert({ username: 'johndoe', age: 30 }).then(response => console.log(response));

// Read records
client.from('users').select('*').then(response => console.log(response));

// Update a record
client.from('users').update({ age: 31 }).eq('username', 'johndoe').then(response => console.log(response));

// Delete a record
client.from('users').delete().eq('username', 'johndoe').then(response => console.log(response));

Filtering Data

This feature allows you to filter data based on specific conditions. The code sample demonstrates how to filter records where the age is 30 and how to use advanced filtering with multiple conditions.

const { createClient } = require('@supabase/postgrest-js');

const client = createClient('https://your-project.supabase.co', 'public-anon-key');

// Filter records
client.from('users').select('*').eq('age', 30).then(response => console.log(response));

// Advanced filtering
client.from('users').select('*').or('age.eq.30,username.eq.johndoe').then(response => console.log(response));

Real-time Subscriptions

This feature allows you to subscribe to real-time changes in your database tables. The code sample demonstrates how to set up a subscription to listen for any changes in the 'users' table and log the changes to the console.

const { createClient } = require('@supabase/postgrest-js');

const client = createClient('https://your-project.supabase.co', 'public-anon-key');

// Subscribe to changes in the 'users' table
const subscription = client.from('users').on('*', payload => {
  console.log('Change received!', payload);
}).subscribe();

Other packages similar to @supabase/postgrest-js

Keywords

FAQs

Package last updated on 05 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc