digitalinteraction / ongoingness-api

API for the Ongoingness Project
BSD 3-Clause "New" or "Revised" License
0 stars 2 forks source link

Deleting Nested Documents #13

Closed wel-shy closed 5 years ago

wel-shy commented 5 years ago

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

  1. Check all fields.
  2. If field is of the type Schema.Types.ObjectId or Schema.Types.ObjectId[]...
  3. Delete the object matching that id, can infer table from the field name.