hack4impact-uiuc / 7000-languages

Helping Indigenous communities around the world teach, learn and sustain their languages
GNU General Public License v3.0
12 stars 2 forks source link

PUT endpoint for batch changes #124

Closed ashayp22 closed 2 years ago

ashayp22 commented 2 years ago

Is your feature request related to a problem? Please describe.

We will need some endpoints that let us make changes to more than one units and lessons at the same time. For example, if we were to re-order the lessons for a specific unit.

Describe the solution you'd like

Let's assume that this is a batch endpoint for making changes to all of the units for a specific _course_id. The input for this endpoint should be a list of units, where a single unit should be in the following format:

{
  name: { type: String, required: true },
  _order: { type: Number, required: true, index: true },
  selected: { type: Boolean, required: true },
  description: { type: String, required: true, default: '' },
}

Once we get the input, we should do the following:

  1. Make sure that the _order goes 0, 1, 2, 3....
  2. For each unit pushed, update its document in MongoDB.

Resources

  1. JavaScript map method
  2. Mongoose documentation
ashayp22 commented 2 years ago

150