diff --git a/scripts/init-db.js b/scripts/init-db.js index 95cead36eba582725d48463867d57a516484973b..52c7ce70bb70524d78a66f44a1ede1ada701094a 100644 --- a/scripts/init-db.js +++ b/scripts/init-db.js @@ -2,7 +2,7 @@ const mongoose = require('mongoose'); // eslint-disable-next-line @typescript-eslint/no-var-requires const userData = require('./data/users'); -const structuresTypesData = require('./data/structuresType'); +const structuresTypeData = require('./data/structuresType'); const categoriesOthersData = require('./data/categoriesOthers'); const categoriesAccompanementsData = require('./data/categoriesAccompanements'); const categoriesFormationData = require('./data/categoriesFormation'); @@ -57,10 +57,13 @@ var usersSchema = mongoose.Schema({ password: String, phone: String, }); -var structuresTypeSchema = mongoose.Schema({ - name: String, - values: [], -}); +var structuresTypeSchema = mongoose.Schema( + { + name: String, + values: [], + }, + { collection: 'structuretype' } +); var categoriesOthersSchema = mongoose.Schema({ name: String, id: String, @@ -144,9 +147,9 @@ mongoose.connection.dropCollection('users', async (err) => { }); /* Create structures ref */ -mongoose.connection.dropCollection('structuretypes', async (err) => { +mongoose.connection.dropCollection('structuretype', async (err) => { await handleError('structureType', err); - structuresType.create(structuresTypesData.data, (error) => { + structuresType.create(structuresTypeData.data, (error) => { if (error) return console.error(error); }); }); @@ -166,7 +169,7 @@ mongoose.connection.dropCollection('categoriesaccompagnements', async (err) => { }); mongoose.connection.dropCollection('categoriesformations', async (err) => { - await handleError('categoriesFormation', err); + await handleError('categoriesFormations', err); categoriesFormation.create(categoriesFormationData.data, (error) => { if (error) return console.error(error); });