обновление логики
This commit is contained in:
@@ -1,14 +1,13 @@
|
||||
// Импортировать mongoose из общего модуля (подключение происходит в server/utils/mongoose.ts)
|
||||
// Импортировать mongoose из общего модуля (подключение происходит автоматически)
|
||||
const mongoose = require('../../../utils/mongoose');
|
||||
const { Event } = require('../models');
|
||||
const Event = require('../models/Event');
|
||||
|
||||
async function recreateTestUser() {
|
||||
try {
|
||||
// Ждем, пока подключение будет готово
|
||||
// Проверяем подключение к MongoDB
|
||||
if (mongoose.connection.readyState !== 1) {
|
||||
await new Promise(resolve => {
|
||||
mongoose.connection.once('connected', resolve);
|
||||
});
|
||||
console.log('Waiting for MongoDB connection...');
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
}
|
||||
|
||||
console.log('Connected to MongoDB');
|
||||
@@ -22,12 +21,11 @@ async function recreateTestUser() {
|
||||
votingEnabled: false
|
||||
});
|
||||
console.log('Test event created:', event.name);
|
||||
} else {
|
||||
console.log('Event already exists:', event.name);
|
||||
}
|
||||
|
||||
console.log('Database initialized successfully');
|
||||
|
||||
await mongoose.disconnect();
|
||||
console.log('Disconnected from MongoDB');
|
||||
} catch (error) {
|
||||
console.error('Error:', error);
|
||||
process.exit(1);
|
||||
|
||||
Reference in New Issue
Block a user