Skip to content
Snippets Groups Projects

fix/fixing-v1.10

Merged Augustin LECONTE requested to merge fix/fixing-v1.10 into dev
1 file
+ 48
0
Compare changes
  • Side-by-side
  • Inline
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;
}
Loading