All Downloads are FREE. Search and download functionalities are using the official Maven repository.

scripts.3.8.0.1-page-acl-migration.js Maven / Gradle / Ivy

There is a newer version: 4.5.2
Show newest version
print('Migrate excluded_groups of Pages to new ACL format');
// Override this variable if you use prefix
const prefix = '';

const pages = db.getCollection(`${prefix}pages`);

pages.find({ excluded_groups: { $exists: true, $not: { $size: 0 } } }).forEach((page) => {
    page.visibility = 'PRIVATE';
    page.excludedAccessControls = true;
    page.accessControls = page.excluded_groups.map((referenceId) => ({ referenceId, referenceType: 'GROUP' }));
    delete page.excluded_groups;
    pages.replaceOne({ _id: page._id }, page);
  }
);

pages.updateMany(
    { accessControls: { $exists: false } },
    { $set: { excludedAccessControls: false, accessControls: [] } },
    {
        upsert: false,
    }
);




© 2015 - 2024 Weber Informatics LLC | Privacy Policy