Files
multy-stub/server/routers/assessment-tools/scripts/recreate-test-user.js

37 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Импортировать mongoose из общего модуля (подключение происходит автоматически)
const mongoose = require('../../../utils/mongoose');
const Event = require('../models/Event');
async function recreateTestUser() {
try {
// Проверяем подключение к MongoDB
if (mongoose.connection.readyState !== 1) {
console.log('Waiting for MongoDB connection...');
await new Promise(resolve => setTimeout(resolve, 1000));
}
console.log('Connected to MongoDB');
// Создаем тестовое мероприятие если его нет
let event = await Event.findOne();
if (!event) {
event = await Event.create({
name: 'Tatar san',
status: 'draft',
votingEnabled: false
});
console.log('Test event created:', event.name);
} else {
console.log('Event already exists:', event.name);
}
console.log('Database initialized successfully');
} catch (error) {
console.error('Error:', error);
process.exit(1);
}
}
recreateTestUser();