annuaire/scripts/import-from-directus/index.js

28 lines
722 B
JavaScript

import { Directus } from '@directus/sdk';
import fs from 'fs';
const directus_url = "https://formulaire.p4pillon.org"
const directus = new Directus(directus_url);
async function getMspInfo() {
const response = await directus.items('MSP_INFO').readByQuery({ sort: ['nofinesset']});
return response.data
}
const mspInfo = await getMspInfo();
const data = {}
for (const msp of mspInfo) {
const nofinesset = msp.nofinesset
const info = msp
delete msp.nofinesset
data[nofinesset] = [
msp.nom,
msp.prenom_leader,
msp.nom_leader,
msp.avec_sante,
msp.accord_conventionnel_interprofessionnel,
];
}
fs.writeFileSync('../../static/data_p4pillon.json', JSON.stringify(data, null, 2) , 'utf-8');