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

scripts.1.0.0.1-copy-members-to-memberships.js Maven / Gradle / Ivy

There is a newer version: 4.5.2
Show newest version
db.apis.find().forEach(
    function(api) {
        for(var i = 0; i < api.members.length; i++) {
            var member = api.members[i];
            db.memberships.insert({
                _id: {
                    userId: member.user.$id, 
                    referenceId: api._id, 
                    referenceType: "API"
                },
                _class: "io.gravitee.repository.mongodb.management.internal.model.MembershipMongo",
                type: member.type,
                createdAt: member.createdAt,
                updatedAt: member.updatedAt
            });
        }
    }
);

db.applications.find().forEach(
    function(application) {
        for(var i = 0; i < application.members.length; i++) {
            var member = application.members[i];
            db.memberships.insert({
                _id: {
                    userId: member.user.$id, 
                    referenceId: application._id, 
                    referenceType: "APPLICATION"
                },
                _class: "io.gravitee.repository.mongodb.management.internal.model.MembershipMongo",
                type: member.type,
                createdAt: member.createdAt,
                updatedAt: member.updatedAt
            });
        }
    }
);




© 2015 - 2024 Weber Informatics LLC | Privacy Policy