As I observe they are the same. In what situation they will differ?
Here's the answer from chatgpt(not really helping)
In the context of a payload CMS, "data" typically refers to the content or metadata that is being stored or retrieved by the CMS. This could include things like article text, images, or other assets.
On the other hand, "siblingData" specifically refers to other content items that are related to the current item being accessed or modified. For example, if you were editing an article in a CMS and wanted to link it to another article, you might use "siblingData" to retrieve a list of other articles that could be linked.
In short, "data" is the primary content or metadata being accessed, while "siblingData" is secondary content or metadata that is related to the primary content.
Hi @Stupidism, Good question!
Suppose you are working on a field hook that needs to use field data in a nested structure that repeats, like the array or blocks fields. If you had to do this with only the data
at the top of the document you would have a terrible time traversing from the top to the correct index and nested field.
It sounds like this is an opportunity to improve our docs.
Here is a simplified example of a collection config where this is apparent:
const fields = [
{
type: 'array',
name: 'top',
hooks: {
afterRead: [
({ data, siblingData }) => {
// data and siblingData are the same at the top, so this one doesn't help
},
],
},
fields: [
{
name: 'nested',
type: 'group',
fields: [
{
name: 'field',
type: 'text',
hooks: {
afterRead: [
({ data, siblingData }) => {
// siblingData.siblingOfField is now very easy to access
},
],
},
},
{
name: 'siblingOfField',
type: 'text',
},
],
},
],
},
]
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.