OK let me try to type this out a little better on my part.
I have two collections a db.users collection and a db.roles collection.
The data on the user collection look like the following:
/* 1 */
{
"_id" : "d65eb800-23c3-11ed-b98c-519bf1f3431f",
"is_active" : true,
"is_verified" : true,
"crm_id" : null,
"role" : "admin",
"ownerSetMFA" : false,
"orgSwitching" : false,
"type" : "User",
"verification_code" : "2db0961b-f67c-49d9-ac2b-0b2140a3136c",
"name" : "Josh test8",
"email" : "test+test8@test.com",
"phone" : "5555555555",
"jobDescription" : "Administrator",
"migrated" : true,
"_organization" : {
"id" : "d65ff080-23c3-11ed-b98c-519bf1f3431f",
"type" : "Organization"
},
with the data on the roles collection looking like this:
{
"_id" : "254480e5-7d32-4756-b748-120da9ef5f2b",
"locationIds" : [
"*"
],
"roomIds" : [
"*"
],
"signageListIds" : [
"*"
],
"signageIds" : [
"*"
],
"deviceIds" : [
"*"
],
"type" : "Role",
"name" : "Admin",
"description" : "Default Ditto Admin Role",
"organizationId" : "ec5b8680-f63a-11ec-a078-253419036b28",
"application" : {
"receivers" : 2,
"rooms" : 2,
"locations" : 2,
"signage" : 2,
"alerts" : 2,
"organization" : 2,
"billing" : 2,
"users" : 2
},
"readOnly" : true,
"createdAt" : ISODate("2022-06-27T17:02:27.904Z"),
"updatedAt" : ISODate("2022-06-27T17:02:27.904Z"),
"__v" : 0
The roles collection is a new collection that was created due to a new feature that was created. We are creating two roles for every organization ID on the users collection an Admin and a User role. So I am working to write a script that will look for the distinct organization id on the user collection and work to created the two roles on the roles collection.
On the roles collection the _id field will be a UUID that is unique to the role.
Does that make a little more sense?