prototypeUrl
renamed to prototypeName
db.repositories.updateMany({}, { $rename: { "prototypeUrl": "prototypeName" } });
ServiceType data model FrontendService
-> frontend
, BackendService
-> backend
db.repositories.updateMany(
{ "serviceType": "BackendService" },
{ $set: { "serviceType": "backend" } }
);
db.repositories.updateMany(
{ "serviceType": "FrontendService" },
{ $set: { "serviceType": "frontend" } }
);
Tag data model AdminFrontend
-> admin
, Stub
-> stub
, Api
-> api
db.repositories.updateMany(
{ "tags": "Stub" },
{ $set: { "tags.$[element]": "stub" } },
{ arrayFilters: [{ "element": "Stub" }] }
);
db.repositories.updateMany(
{ "tags": "AdminFrontend" },
{ $set: { "tags.$[element]": "admin" } },
{ arrayFilters: [{ "element": "AdminFrontend" }] }
);
db.repositories.updateMany(
{ "tags": "Api" },
{ $set: { "tags.$[element]": "api" } },
{ arrayFilters: [{ "element": "Api" }] }
);
Data model changes from teams with repos, to repos with teams.
db.getCollection('teamsAndRepositories').aggregate([
{$unwind: "$repositories"}
,{$group: {
_id: "$repositories.name",
repositories: {$max: "$repositories"},
teams: {$addToSet: "$teamName"},
}
}
,{$addFields: {"repositories.teamNames":"$teams" }}
,{$replaceRoot: {newRoot: "$repositories"} }
,{$addFields: {"isArchived": "$archived"}}
,{$project: {archived: 0}}
,{$out: "repositories"}
])
db.getCollection('updateTime').drop()
db.getCollection('teamsAndRepositories').renameCollection('teamsAndRepositories-bak')
db.getCollection('teamsAndRepositories-bak').aggregate([
{
$addFields: {
repositories: {
$map: {
input: '$repositories',
as: 'repository',
in: {
$mergeObjects: [
"$$repository",
{
createdDate: { $toDate: "$$repository.createdDate" },
lastActiveDate: { $toDate: "$$repository.lastActiveDate" }
}
]
}
}
},
updateDate: { $toDate: "$updateDate"},
}
},
{ $out: "teamsAndRepositories" }
]);