@@ -285,6 +285,39 @@ export default class MutableClimbDataSource extends ClimbDataSource {
285285 }
286286 }
287287
288+ /**
289+ * Update a single climb by its ID. Unlike addOrUpdateClimbs, this doesn't require the parent area ID.
290+ * @param userId User performing the action
291+ * @param climbId The climb's own ID
292+ * @param changes The fields to update
293+ * @returns The updated climb, or null if not found
294+ */
295+ async updateClimbById ( userId : MUUID , climbId : MUUID , changes : Omit < ClimbChangeInputType , 'id' > ) : Promise < ClimbType | null > {
296+ // Look up the climb to get its parent area ID
297+ const climb = await this . climbModel . findOne ( { _id : climbId , _deleting : { $eq : null } } ) . lean ( )
298+
299+ if ( climb == null ) {
300+ throw new GraphQLError ( `Climb with id: ${ climbId . toUUID ( ) . toString ( ) } not found` , {
301+ extensions : {
302+ code : ApolloServerErrorCode . BAD_USER_INPUT
303+ }
304+ } )
305+ }
306+
307+ const parentId = climb . metadata . areaRef
308+
309+ // Use existing logic with the climb ID included
310+ const changeWithId : ClimbChangeInputType = {
311+ ...changes ,
312+ id : climbId . toUUID ( ) . toString ( )
313+ }
314+
315+ await this . addOrUpdateClimbs ( userId , parentId , [ changeWithId ] )
316+
317+ // Return the updated climb
318+ return await this . climbModel . findOne ( { _id : climbId } ) . lean ( )
319+ }
320+
288321 /**
289322 * Delete one or more climbs by climb ID.
290323 * @param userId User performing the action
0 commit comments