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

feat (migrations) : add label conseiller numerique france service

parent 60cf9016
No related branches found
No related tags found
2 merge requests!96release V1.10.0,!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