Bumps [es5-ext](https://github.com/medikoo/es5-ext) from 0.10.62 to 0.10.64. - [Release notes](https://github.com/medikoo/es5-ext/releases) - [Changelog](https://github.com/medikoo/es5-ext/blob/main/CHANGELOG.md) - [Commits](https://github.com/medikoo/es5-ext/compare/v0.10.62...v0.10.64) --- updated-dependencies: - dependency-name: es5-ext dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Payload Hierarchy Example
This example demonstrates how to achieve a virtual hierarchy between documents in your Payload application.
Quick Start
To spin up the project locally, follow these steps:
- First clone the repo
- Then
cd YOUR_PROJECT_REPO && cp .env.example .env - Next
yarn && yarn dev(ordocker-compose up, see Docker) - Now
open http://localhost:3000/adminto access the admin panel - Create your first admin user using the form on the page
That's it! Changes made in ./src will be reflected in your app.
How it works
This example achieves parent/child relationships between your documents through the use of virtual fields. When you query a document with the ?children=true query param, an afterRead hook is used to populate the documents within its own tree.
For more information on how virtual fields, see the Official Virtual Fields Example.
Collections
See the Collections docs for details on how to extend any of this functionality.
-
Users
The
userscollection is a default payload users collection. -
Entities
The
entitiescollection can define a parent as any other entity. It has a virtual field that will also populate children when it is called via the API using a querychildren=true. See Virtual Fields for more details on how virtual fields work.The virtual field retrieves all children which includes other entities and people.
-
People
The
peoplecollection is a collection that can define an array of parent entities. It also has an allocation field. This is for demonstrating attaching data to a parent-child relationship.
Development
To spin up this example locally, follow the Quick Start.
Production
To run Payload in production, you need to build and serve the Admin panel. To do so, follow these steps:
- First invoke the
payload buildscript by runningyarn buildornpm run buildin your project root. This creates a./builddirectory with a production-ready admin bundle. - Then run
yarn serveornpm run serveto run Node in production and serve Payload from the./builddirectory.
Deployment
The easiest way to deploy your project is to use Payload Cloud, a one-click hosting solution to deploy production-ready instances of your Payload apps directly from your GitHub repo. You can also deploy your app manually, check out the deployment documentation for full details.
Questions
If you have any issues or questions, reach out to us on Discord or start a GitHub discussion.