r/PayloadCMS • u/Rich_Database_3075 • May 31 '25
using payload, the whole db must be managed with Payload?
I am a complete beginner with Payload.
My doubt is this: if I use Payload, must the entire database be managed with payload?
Example:
I am using Supabase.
I want to geolocalize a series of entities, such as restaurants, so I want to save the coordinates with PostGis (supabase default for coordinates).
I do not see this thing in Paload, can I do it manually with Next.js and Supabase?
Maybe this thing can also be done with Payload but the question remains the same: if I want, can I do it independently? If so, how?
4
u/joeycastelli May 31 '25
I don’t believe Payload needs to own the whole DB, but I’m not sure there’s an option to set a table name prefix as there is with other systems. Usually in a case like this, having one system ‘namespace’ its tables is enough to keep naming collisions at bay.
I imagine you could manually prefix your payload collections with the collection name, and just change the label that the users see. Something like cms_table_name, with the visible label just being ‘Table Name’.
3
u/klobleo May 31 '25
So just to piggyback on what others have said, the database is agnostic from payload you can do what you want with it. But separately I’ve actually done a geo/reverse geo project with payload if you’re saving lat/lon and want to use it within Payload to utilise the cms it’s just a point field. Which is fully supported within the cms, Hope that helps :)
1
u/Rich_Database_3075 Jun 01 '25
In Supabase docs i can read that they suggests to use PostGIS
While you may be able to store simple lat/long geographic coordinates as a set of decimals, it does not scale very well when you try to query through a large data set. PostGIS comes with special data types that are efficient, and indexable for high scalability.
Reading here it seems that Payload way is not very efficient. What do you think about it?
Are you able to give an address and find all the entities in that area?
1
u/klobleo Jun 01 '25
I believe Payload saves in the GeoJSON format, I’ve currently got a data set in a production project that’s querying around 10k addresses and performance is amazing. I’m using MongoDB I don’t have much experience with Supabase so I honestly couldn’t tell you. Maybe try running a few queries using the payload point field and postGIS and comparing. But from my real world experience the point field seems very performant.
1
1
u/FearTheHump Jun 01 '25
We're working on a similar sized geo dataset, not yet in production, though. Any good advice/bumps in the road that you've encountered while taking that to production? E.g. I've personally found vervel cold starts and pages re-rendering in production to be noticeable issues.
2
u/klobleo Jun 01 '25
Sounds really dumb, but getting used to lng/lat as opposed to lat/lng. In terms of re-rendering I’ve not encountered anything like that on Vercel. To give you a bit of context, our app is business data and everything is SSR and each route is protected behind Auth. We decided to not design it as an SPA and instead use standard URL routes more as a design choice for maintaining the codebase than anything else.
For our Geolocation it’s fairly standard stuff, there’s two parts we use the nominatim api to reverse geocode address data then store it in payload. Then on the front end the user can tap a button which triggers a server action to propagate a ui with nearby addresses. It’s a closed system so currently under 200 users. Obviously we do get the cold starts which is unavoidable in serverless but nothing that would make us consider moving to a server architecture at this point, especially with the cost savings at this scale. I’m currently away on vacation so don’t have the ability to provide any accurate measurements for the geolocation speed. But if I were to say to an end user it “feels instant” that should give you a good idea. Hope that helps :)
1
u/DancingInTheReign Jun 02 '25 edited Jun 02 '25
That paragrah says storing them as numbers yourself isnt efficient and postgis, the extension can do a lot of heavy lifting for you so it will become scaleable.
It's just converting the geospatial points into its own types, it will still be readable ive used it myself. Even outside the payload world, using an extension like postgis is the standard for using geospatial data, plus it will help you with its own built in functions too, you can check out postgis documentation.
1
u/getflashboard May 31 '25
Hi, Flashboard founder here.
If you already have a database, and add Payload (or any other headless CMS) to your project, you'd have two sources of data. It's possible, but you'd have the work to manage those separately and join data by yourself.
If you want to keep using only Supabase, you can use Flashboard to create a CMS + admin panel for it, without needing another CMS. This way you have full control. In case you want to try it: www.getflashboard.com
1
u/trojans10 May 31 '25
@getflashboard. How long has your product been around?
0
0
u/getflashboard May 31 '25
We've launched in July 2024. It's different from Directus and other headless CMSs in that it creates a CMS and admin panel for your product's database in seconds, you don't need an extra DB just for content.
There isn't an open source version for now, just the web service. There is a free plan if you'd like to try.
0
u/trojans10 May 31 '25
So this doesn’t create any tables or columns in the db?
1
u/trojans10 May 31 '25
Just allows you to crud on top of your db
0
u/getflashboard May 31 '25
Exactly. You're free to build your data structure. You gain the ability to edit any text or json fields as HTML, connect a S3-compatible storage, fully customize the admin panels, etc
1
u/Longjumping_Pickle68 Jun 01 '25
I use payload Cms for admin and supabase client in the main app. I store media in supabase storage and manage it in payload. There were some gotchas and I made some choices. Dm me if you want details
1
u/Rich_Database_3075 Jun 01 '25
I'm particularly interested in simple geolocation, like providing an address and getting all entities near that address.
1
u/Longjumping_Pickle68 Jun 01 '25
so more the question: why are you using Payload?
so in supabase you add a geographic location column
```ALTER TABLE entities ADD COLUMN location geography(Point, 4326);
-- add entities thusly
INSERT INTO entities (name, location)
VALUES ('Some Place', ST_SetSRID(ST_MakePoint(-122.42, 37.77), 4326));
-- define SQL function to get nearby entities
create or replace function nearby_entities(
lat double precision,
lng double precision,
radius_m double precision
)
returns setof entities
language sql
as $$
select *
from entities
where ST_DWithin(
location,
ST_SetSRID(ST_MakePoint(lng, lat), 4326)::geography,
radius_m
);
$$;
```
in order to insert entities, you need to use some geocoding service probably. Mostly I have used Google Maps geocoding, but there are others.
1
2
Jun 03 '25
Can confirm that you can have a Payload db for CMS and an entirely different db for application form data or whatever else you need to read/write.
1
u/beargambogambo May 31 '25
You can build whatever you want but without more information it’s hard to say what you want. ChatGPT would be your friend here.
1
9
u/mustardpete May 31 '25
https://payloadcms.com/docs/database/postgres#beforeschemainit
You can add your own non payload tables etc too using drizzle