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

scripts.3.3.0.1-update-users-and-identityProviders.js Maven / Gradle / Ivy

There is a newer version: 4.5.2
Show newest version
print('In users collection, \'referenceId\' and \'referenceType\' are replaced with \'organizationId\'');
db.users.find({}).forEach(user => {
    if (!user.organizationId) {
        const organizationId = user.referenceId;
        db.users.updateOne(
            { '_id': user._id },
            {
                $set: { 'organizationId': organizationId },
                $unset: { 'referenceId': '', 'referenceType': '' }
            }
        );
    }
});

print('In identity_providers collection, \'referenceId\' and \'referenceType\' are replaced with \'organizationId\'');
db.identity_providers.find({}).forEach(idp => {
    if (!idp.organizationId) {
        const organizationId = idp.referenceId;
        db.identity_providers.updateOne(
            { '_id': idp._id },
            {
                $set: { 'organizationId': organizationId },
                $unset: { 'referenceId': '', 'referenceType': '' }
            }
        );
    }
});




© 2015 - 2024 Weber Informatics LLC | Privacy Policy