Need to have a flag to check if a resource has linked resource. It should then delete these resources before deleting the parent resource. Can add flags to delete all media and devices if resource being is deleted is a user, but best to make this more general. Needs to be implemented in MongoResourceRouter.ts@destroy.
Possible Solutions
Check all fields.
If field is of the type Schema.Types.ObjectId or Schema.Types.ObjectId[]...
Delete the object matching that id, can infer table from the field name.
Deleting Nested Documents in Mongo :bug:
Need to have a flag to check if a resource has linked resource. It should then delete these resources before deleting the parent resource. Can add flags to delete all media and devices if resource being is deleted is a user, but best to make this more general. Needs to be implemented in
MongoResourceRouter.ts@destroy
.Possible Solutions
Schema.Types.ObjectId
orSchema.Types.ObjectId[]
...