PayloadCMS & local first apps: User defined document IDs #4398
Closed
ccssmnn
started this conversation in
Feature Requests & Ideas
Replies: 1 comment
-
I just found the Customizable IDs section in the docs. https://payloadcms.com/docs/fields/overview#customizable-id |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I would love to use Payload with a local-first frontend. The local first approach, however, requires the client to assign IDs. Example:
A user could create a team and assign organization members to this team, all of which are first stored in the local cache and can later be synced with the server.
Ideally, we could set the IDs when creating documents using REST, GraphQL, or local APIs.
In my concrete case, I use Replicache as the local cache. I can implement the sync protocol using custom endpoints and the Payloads Local API. Access control would be declarative and handled by Payload, and I get Auth, Admin-UI, and REST and GraphQL endpoints for free.
As a temporary workaround, I could store a “key” in every document that is used to store and reference the documents inside the local cache. This adds overhead for setting up the cache (Client View in Replicache terminology), since inside Payload the document IDs are stored for referencing related documents where the key is used inside the local cache. When applying mutations on the server, there is overhead too because I need to find the affected document by its key first.
Beta Was this translation helpful? Give feedback.
All reactions