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

feat(structure): add service venteMaterielPrixSolidaire

parent c9633621
No related branches found
No related tags found
3 merge requests!97release V1.10.0,!96release V1.10.0,!89feat/US2-add-service-vente-materiel-prix-solidaire
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 == 'equipmentsAndServices') {
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 == 'equipmentsAndServices') {
const newDoc = downgradeLabel(document);
await db.collection('categoriesothers').updateOne({ _id: document._id }, [{ $set: newDoc }]);
}
}
console.log(`Update done`);
};
function updateLabel(doc) {
if (doc.modules) {
doc.modules.push({
id: 'venteMaterielPrixSolidaire',
text: 'Vente de matériel à prix solidaire',
});
}
return doc;
}
function downgradeLabel(doc) {
if (doc.modules) {
doc.modules = doc.modules.filter(function (elem) {
return elem.id != 'venteMaterielPrixSolidaire';
});
}
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