Package Exports
- @supabase/postgrest-js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@supabase/postgrest-js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Postgrest JS
Isomorphic JavaScript client for PostgREST. The goal of this library is to make an "ORM-like" restful interface.
Contents
Usage
Install
npm install --save @supabase/postgrest-js
Initialize
import { PostgrestClient } from ' @supabase/postgrest-js'
let client = new PostgrestClient('https://your-postgrest.com')
GET
// Basic
let { body: countries } = await client
.from('countries')
.select('*')
// Getting specific columns
let { body: countries } = await client
.from('countries')
.select('name')
// Query foreign tables
let { body: countries } = await client
.from('countries')
.select(`
name,
cities (
name
)
`)
// Filter foreign tables
let { body: countries } = await client
.from('countries')
.select(`
name,
cities (
name
)
`)
.filter('name', 'eq', 'New Zealand')
.filter('cities.name', 'eq', 'Auckland')
// Ordering
let { body: countries } = await client
.from('countries')
.select('name')
.order('name')
// Pagination
let { body: countries } = await client
.from('countries')
.select('name')
.range(0, 10)
// Match
let { body: countries } = await client
.from('countries')
.match({ 'continent': 'Asia' })
.select('*')
// Equal
let { body: countries } = await client
.from('countries')
.eq('name', 'New Zealand')
.select('*')
// Greater than
let { body: countries } = await client
.from('countries')
.gt('id', 20)
.select('*')
// Less than
let { body: countries } = await client
.from('countries')
.lt('id', 20)
.select('*')
// Greater than or equal
let { body: countries } = await client
.from('countries')
.gte('id', 20)
.select('*')
// Less than or equal
let { body: countries } = await client
.from('countries')
.lte('id', 20)
.select('*')
// String search - case sensitive
let { body: countries } = await client
.from('countries')
.like('name', '%Zeal%')
.select('*')
// String search - case insensitive
let { body: countries } = await client
.from('countries')
.ilike('name', '%Zeal%')
.select('*')
// Exact equality (null, true, false)
let { body: countries } = await client
.from('countries')
.is('name', null)
.select('*')
// In list
let { body: countries } = await client
.from('countries')
.in('name', ['China', 'France'])
.select('*')
// Not equal
let { body: countries } = await client
.from('countries')
.not('name', 'China')
.select('*')
POST
You can insert records using insert()
. Insert accepts an array of objects so that you can batch insert.
let { status } = await client
.from('messages')
.insert([{ message: 'Hello World 👋'])
PATCH
You can update records using update()
.
let { status } = await client
.from('messages')
.eq('message', 'Hello World 👋')
.update({ message: 'Goodbye World 👋' })
DELETE
You can delete records using delete()
.
let { status } = await client
.from('messages')
.eq('message', 'Goodbye World 👋')
.delete()
Usage online
To see details examples of usage, see the Supabase docs:
Contributing
- Fork the repo on GitHub
- Clone the project to your own machine
- Commit changes to your own branch
- Push your work back up to your fork
- Submit a Pull request so that we can review your changes and merge
Release Notes
gren release --override
This will create the changelog and the release.
License
This repo is liscenced under MIT.
Credits
- https://github.com/calebmer/postgrest-client - originally forked and adapted from @calebmer's library
Status
Ready for production! Watch and star this repo to keep updated on releases.