도커 컨테이너에서 목업 데이터 넣는법
db들어가기 : docker exec -it dupilot-mongo mongosh -u root -p example --authenticationDatabase admin dupilot
db에 데이터 넣기:
const langKoreanId = new ObjectId();
const langEnglishId = new ObjectId();
const translatorId = new ObjectId();
const adminId = new ObjectId();
const projectId = new ObjectId();
const seg1Id = new ObjectId();
const seg2Id = new ObjectId();
const issueId = new ObjectId(); // 기존 issue ID가 있다면 교체하세요
function dropIfExists(name) {
if (db.getCollectionNames().includes(name)) {
print(`Dropping ${name}...`);
db.getCollection(name).drop();
}
}
dropIfExists('user');
dropIfExists('language');
dropIfExists('projects');
print("Inserting languages...");
db.language.insertMany([
{ _id: langKoreanId, language: "Korean" },
{ _id: langEnglishId, language: "English" }
]);
print("Inserting users...");
db.user.insertMany([
{
_id: translatorId,
user_email: "translator@example.com",
user_password: "password123",
role: "translator",
language_ids: [langKoreanId, langEnglishId],
created_at: new Date(),
updated_at: new Date()
},
{
_id: adminId,
user_email: "admin@example.com",
user_password: "admin_password456",
role: "admin",
language_ids: [langKoreanId],
created_at: new Date(),
updated_at: new Date()
}
]);
print("Inserting project...");
db.projects.insertOne({
_id: projectId,
video_source: "s3://my-bucket/video/project_alpha.mp4",
audio_source: "s3://my-bucket/audio/project_alpha.mp3",
created_at: new Date(),
updated_at: new Date(),
editor_id: translatorId,
segments: [
{
segment_id: seg1Id,
segment_text: "첫 번째 원문 텍스트입니다.",
score: 0.95,
start_point: 0.5,
end_point: 3.2,
editor_id: translatorId,
translate_context: "This is the first original text.",
sub_langth: 2.7,
issues: [
{
issue_id: issueId,
editor_id: translatorId
}
]
},
{
segment_id: seg2Id,
segment_text: "두 번째 원문 텍스트입니다. 여기는 이슈가 없습니다.",
score: 0.99,
start_point: 3.5,
end_point: 5.8,
editor_id: translatorId,
translate_context: "This is the second original text. No issues here.",
sub_langth: 2.3,
issues: []
}
]
});
print("Mock seed done.");