Skip to content
Snippets Groups Projects
Commit 9635fb38 authored by Hugo NOUTS's avatar Hugo NOUTS
Browse files

Merge branch 'dev' into 'master'

feat (migrations) : add label conseiller numerique france service

See merge request web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server!85
parents e57ed8a5 b310d9d2
No related branches found
No related tags found
2 merge requests!86feat/US1-admin-remove-from-struct,!85feat (migrations) : add label conseiller numerique france service
......@@ -21,7 +21,7 @@ export const down = async () => {
const cursor = db.collection('categoriesothers').find({});
let document;
while ((document = await cursor.next())) {
if (document.id == 'labelsQualification') {
if (document.id == 'labelsQualifications') {
const newDoc = downgradeLabel(document);
await db.collection('categoriesothers').updateOne({ _id: document._id }, [{ $set: newDoc }]);
}
......
import { Db } from 'mongodb';
import { getDb } from '../migrations-utils/db';
export const up = async () => {
const db: Db = await getDb();
const cursor = db.collection('categoriesothers').find({});
let document;
while ((document = await cursor.next())) {
if (document.id == 'labelsQualifications') {
const newDoc = updateLabel(document);
await db.collection('categoriesothers').updateOne({ _id: document._id }, [{ $set: newDoc }]);
}
}
console.log(`Update done`);
};
export const down = async () => {
const db: Db = await getDb();
const cursor = db.collection('categoriesothers').find({});
let document;
while ((document = await cursor.next())) {
if (document.id == 'labelsQualifications') {
const newDoc = downgradeLabel(document);
await db.collection('categoriesothers').updateOne({ _id: document._id }, [{ $set: newDoc }]);
}
}
console.log(`Update done`);
};
function updateLabel(doc) {
doc = addCNFS(doc);
return doc;
}
function downgradeLabel(doc) {
doc = removeCNFS(doc);
return doc;
}
function removeCNFS(doc) {
if (doc.modules) {
doc.modules = doc.modules.filter(function (elem) {
return elem.id != 'conseillerNumFranceServices';
});
}
return doc;
}
function addCNFS(doc) {
if (doc.modules) {
doc.modules.push({
id: 'conseillerNumFranceServices',
text: 'Conseiller numérique France services',
});
}
return doc;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment