хорошо, у меня есть эти 2 схемы, где первая называется Миссиями, а другая называется Отчеты. Я боюсь, что моя структура каким-то образом вызовет у меня плохую работу, если она не будет следовать передовой практике MongoDB. И заполнение многих вложенных ObjectIds также замедлит мои запросы? Спасибо.
const MissionSchema = new schema({
title: {
type: String,
required: true
},
description: {
type: String
},
manager: {
type: schema.Types.ObjectId,
ref: "managers"
},
agent: {
type: schema.Types.ObjectId,
ref: "agents"
},
created_at: {
type: Date,
default: Date.now
},
mission_deadline: {
type: Date
},
questionnaires: [
{
type: schema.Types.ObjectId,
ref: "questionnaire"
}
],
clients: [
{
deadline: {
type: Date,
default: null
},
client: {
type: schema.Types.ObjectId,
ref: "clients"
},
visited: {
type: Boolean,
default: false
},
visit_time: {
type: Date,
default: Date.now()
},
valid: {
type: Boolean
},
coords: [],
duration: String,
unavailability_reason: {
type: String,
enum: [
"closed",
"not enough money",
"have enough products",
"come back later",
"other"
]
}
}
],
mission_completed: {
type: Boolean,
default: false
}
});
и вот моя схема отчета
const RepportSchema = new schema({
mission: {
type: schema.Types.ObjectId,
ref: "missions"
},
client: {
type: schema.Types.ObjectId,
ref: "clients"
},
mission_answers: [
{
question: {
type: schema.Types.ObjectId
},
answer: String
}
],
product_answers: [
{
product: {
type: schema.Types.ObjectId,
ref: "products"
},
questions: [
{
question: { type: schema.Types.ObjectId },
answer: String
}
]
}
]
});