Есть три сущности: user, task & project
ВОПРОС: Как при удалении task например, удалить ссылки на нее у user и project?
Как правильно осуществляется поиск по коллекции в таких случаях?
Возможно, я неправильно организовала само хранение данных.
В массивах projects, tasks, developers хранится ObjectId соответствующих сущностей.
Схема user:
{
"_id": {
"$oid": "5f7c39b9871108e68c2f05d3"
},
"position": "developer",
"isActive": true,
"projects": [],
"tasks": [{
"$oid": "5f65f18d95d65e3163c9dbda"
}, {
"$oid": "5f6efbc1a986526f5df0de2b"
}, {
"$oid": "5f7b283015d2c359de263d96"
}],
"username": "Robert Kabakov",
"email": "RobertKabakov@gmail.com",
"password": "$2b$10$t3UrCUadw3yJuVTRftZZJetchjXLn.7Y6LvAqv1KvwWkSGNwRKzli",
"activeToken": "6396e0682231a887d8add1c87f999b0b",
"activeExpires": {
"$date": {
"$numberLong": "1600599704592"
}
},
"createdAt": {
"$date": {
"$numberLong": "1600513304670"
}
Схема project:
{
"_id": {
"$oid": "5f7c3a1d871108e68c2f05d4"
},
"developers": [],
"tasks": [],
"name": " What is Lorem Ipsum?",
"content": "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.",
"manager": {
"$oid": "5f65e5ebb08750307e2bc0d5"
},
"createdAt": {
"$date": {
"$numberLong": "1601973271567"
}
},
"updatedAt": {
"$date": {
"$numberLong": "1601973271567"
}
},
"__v": {
"$numberInt": "0"
}
}
Схема task:
{
"_id": {
"$oid": "5f7c3a1d871108e68c2f05d4"
},
"developers": [],
"tasks": [],
"name": " What is Lorem Ipsum?",
"content": "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.",
"manager": {
"$oid": "5f65e5ebb08750307e2bc0d5"
},
"createdAt": {
"$date": {
"$numberLong": "1601973271567"
}
},
"updatedAt": {
"$date": {
"$numberLong": "1601973271567"
}
},
"__v": {
"$numberInt": "0"
}
}