I have the following fictional scenario. For the collection "media" I have these admin.defaultColumns
defined:
[
'filename',
'height'
]
A couple of users fiddle around with the overview and decide they don't want the height
column so they turn it off. This change is now saved as a preference. Now with a new deployment of my CMS, I added a new column: title
. I added that to the admin.defaultColumns
which now look like
[
'filename',
'height',
'title'
]
How can I make the all users see the title
column without asking them to add it theirselves? Is it possible to reset all user preferences with a single press of a button, or prevent that column changes are persisted?
Aggregations are a mongoDB way to chain commands together. In this case I'm just finding and updating one collection. This would be a one time update to data in the database coinciding with your config changes.
It is typical of other frameworks to have migrations for changing schema and modifying data to an existing database. We are kicking off migrations and additional database support work this week.
For now you can do it from a script or database tool like MongoDB Compass.
There isn't a "single press of a button" option for this, but you could update your preferences collection to do it fairly easily.
Here is an aggregation that will handle your fictional scenario changes for you:
[
{
$match:
{
key: {
$eq: "media-list",
},
},
},
{
$set:
{
value: {
columns: ['filename', 'height', 'title'],
},
},
},
]
Thanks for your quick answer @DanRibbens. I am not familiar with aggregations and I don't see anything about it in Payload documentation. How can I integrate those aggregations in a project?
Aggregations are a mongoDB way to chain commands together. In this case I'm just finding and updating one collection. This would be a one time update to data in the database coinciding with your config changes.
It is typical of other frameworks to have migrations for changing schema and modifying data to an existing database. We are kicking off migrations and additional database support work this week.
For now you can do it from a script or database tool like MongoDB Compass.
Star
Discord
online
Get dedicated engineering support directly from the Payload team.