Skip to content
Snippets Groups Projects
Commit 99f59639 authored by Augustin LECONTE's avatar Augustin LECONTE
Browse files

fix: change france-services migration

parents 91e73238 d0bfb361
No related branches found
No related tags found
3 merge requests!97release V1.10.0,!96release V1.10.0,!95fix/fixing-v1.10
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 = updateText(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 = downgradeText(document);
await db.collection('categoriesothers').updateOne({ _id: document._id }, [{ $set: newDoc }]);
}
}
console.log(`Update done`);
};
function updateText(doc) {
doc.modules = doc.modules.filter((elem) => elem.id !== 'maisonFranceService');
doc.modules.push({
id: 'maisonFranceService',
text: 'Maison France services',
});
return doc;
}
function downgradeText(doc) {
doc.modules = doc.modules.filter((elem) => elem.id !== 'maisonFranceService');
doc.modules.push({
id: 'maisonFranceService',
text: 'Maison France Service',
});
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