Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

created tab for insert

dshukertjr228e913062f5
diff --git a/apps/docs/pages/guides/database/extensions/postgis.mdx b/apps/docs/pages/guides/database/extensions/postgis.mdx
index 39df6a29c2e..d6f3d18c4c0 100644
--- a/apps/docs/pages/guides/database/extensions/postgis.mdx
+++ b/apps/docs/pages/guides/database/extensions/postgis.mdx
@@ -52,7 +52,7 @@ Let’s create our table. Each row represents a restaurant with its location sto
```sql
create table if not exists public.restaurants (
- id uuid not null primary key default uuid_generate_v4 (),
+ id int generated by default as identity primary key,
name text not null,
location geography(POINT) not null
);
@@ -70,13 +70,24 @@ create index restaurants_geo_index
You can insert geographical data through SQL or through our API.
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="sql"
+>
+<TabPanel id="sql" label="SQL">
+
```sql
insert into public.restaurants
(name, location)
values ('Supa Burger', st_point(-73.946823 40.807416));
```
-```tsx
+</TabPanel>
+<TabPanel id="js" label="JavaScript">
+
+```typescript
const location = { lat: 40.807416, long: -73.946823 }
const { error } = await supabase.from('restaurants').insert({
name: 'Supa Burger',
@@ -84,11 +95,25 @@ const { error } = await supabase.from('restaurants').insert({
})
```
-Notice that the order in which you pass the latitude and longitude is longitude first. This is because longitude represents the location on the x-axis. Also, there is no comma between the two values, just a single space.
+</TabPanel>
+<TabPanel id="dart" label="Dart">
+
+```dart
+final location = { 'lat': 40.807416, 'long': -73.946823 };
+await supabase.from('restaurants').insert({
+ name: 'Supa Burger',
+ location: 'POINT(${location['long']} ${location['lat']})',
+});
+```
+
+</TabPanel>
+</Tabs>
+
+Notice the order in which you pass the latitude and longitude. Longitude comes first, and is because longitude represents the x-axis of the location. Another thing to watch for is that there is no comma between the two values, just a single space.
At this point, if you go into your Supabase dashboard and look at the data, you will notice that the data in the location column looks something like this and is not in a human-readable format.
-```tsx
+```
0101000020E6100000A4DFBE0E9C91614044FAEDEBC0494240
```
@@ -109,7 +134,7 @@ as $$
$$;
```
-```tsx
+```typescript
const { data, error } = await supabase.rpc('nearby_restaurants_with_distance', {
lat: 35.6762,
long: 140.6503,
@@ -119,19 +144,19 @@ const { data, error } = await supabase.rpc('nearby_restaurants_with_distance', {
```json
[
{
- "id": "e97c850f-c623-49b3-a226-aabf42668868",
+ "id": 1,
"name": "Supa Burger",
"location": "POINT(-73.946823 40.807416)",
"dist_meters": 14.73033739
},
{
- "id": "09c0aca9-b344-44ae-9e24-2150283f160c",
+ "id": 2,
"name": "Supa Pizza",
"location": "POINT(-73.94581 40.807475)",
"dist_meters": 78.28980007
},
{
- "id": "b0cc0d84-57d7-42ca-9a7f-af28d1614ad1",
+ "id": 3,
"name": "Supa Taco",
"location": "POINT(-73.945826 40.80629)",
"dist_meters": 136.04329002
@@ -163,7 +188,7 @@ $$;
You can call this function from your client like this:
-```tsx
+```typescript
const { data, error } = await supabase.rpc('restaurants_in_view', {
min_lat: 40.807,
min_long: -73.946,
@@ -175,7 +200,7 @@ const { data, error } = await supabase.rpc('restaurants_in_view', {
```json
[
{
- "id": "09c0aca9-b344-44ae-9e24-2150283f160c",
+ "id": 2,
"name": "Supa Pizza",
"location": "POINT(-73.94581 40.807475)"
}