#Skip Save to Payload's Database

1 messages · Page 1 of 1 (latest)

bitter echo
#

Hello everyone, I have some available data sets that I want to fetch to Payload and apply CRUD Operations on them, but only via REST API. I do not want to save these data in the Payload's database. Only to be able to see it and edit it.

Is this possible?

knotty mirageBOT
sour terrace
#

I believe you can effectively do this with custom endpoints.

ruby moth
#

Agree with Brian, you could create custom endpoints and do pretty much anything there 🙂

bitter echo
#

Thank you for the replies. For example, I can use a custom endpoint .../orders/ that fetches all the orders from my data set and a /order/id that updates the specific order from the admin form?

#

And I do not want the orders to be in the database of payload

#

Just fetch them, edit, end.

ruby moth
#

Yeah, it’s absolutely possible. The custom endpoints do what you tell them to do. But I re-read your post and I just need you to clarify “only to be able to see it and edit it” - do you mean in your payload admin panel?

bitter echo
# ruby moth Yeah, it’s absolutely possible. The custom endpoints do what you tell them to do...

Yes to be able to see and edit them in the payload cms without them being actually saved in the payload database. In the payload database I want just the users for authentication, authorisation and some global settings for each tenant. Basically I want user A to login to payload, authenticate and authorise to which tenant he belongs to, and then the orders and products to be fetched with rest api from an external system. Then the user can edit the order/product and when he clicks to save, an http request should be sent to the external system to save/update it.

ruby moth
#

Okay, that makes it a bit more clear. So you're trying to use Payload as a CMS for another system, I guess. I'm not entirely sure if custom endpoints is the way to go for that then.

My first option would be to simply store/sync the external system with payload and store them. When something changes in Payload you then have a hook that updates the external system on change.
And perhaps some sort of hook that fetches from the external system either periodically or for example when the item is read.

(Or if there's support for like webhooks in the external system, pretty common for ecom, have it ping payload that it's updated and needs updating on payloads end)

bitter echo
#

Yes you are correct, that's what I'm thinking but I don't really want to save everything in PayloadCMS database because the costs would be huge and since I am paying already for the cost of the external system I want to leverage that.

ruby moth
#

That makes sense. Maybe it's possible to just save the reference (id) to the order/product and have it fill the fields in like beforeRead and then when saving it afterChange send the updated data to the external system and reset the fields before saving to Payload.

#

My only concern is the amount of fetches that would have to be done and the amount of traffic, if that's more costly than actually storing it. Do you have any sort of traffic limits on either host?

bitter echo
#

I have 100k/day api limit, when implementing caching on payload and frontend I think I can be very much inside this limit.