Skip to content
Snippets Groups Projects
Commit 3bb52d0a authored by Antonin COQUET's avatar Antonin COQUET
Browse files

feat: add women to public list

parent c112c287
No related branches found
No related tags found
3 merge requests!96release V1.10.0,!83Dev,!74feat: add women to public list
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 == 'publics') {
const newDoc = updatePublic(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 == 'publics') {
const newDoc = downgradePublic(document);
await db.collection('categoriesothers').updateOne({ _id: document._id }, [{ $set: newDoc }]);
}
}
console.log(`Update done`);
};
function updatePublic(doc) {
doc = addWomen(doc);
return doc;
}
function downgradePublic(doc) {
doc = removeWomen(doc);
return doc;
}
function removeWomen(doc) {
if (doc.modules) {
doc.modules = doc.modules.filter(function (elem) {
return elem.id != 'women';
});
}
return doc;
}
function addWomen(doc) {
if (doc.modules) {
doc.modules.push({
id: 'women',
text: 'Femmes',
});
}
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