Preventing aggregation pipeline to access courses inside skills


To maintain service boundaries and ensure proper separation of concerns within our microservice architecture, direct aggregation lookups ($lookup) from the skills context into the courses collection must be avoided.

    const documents = await this.model.aggregate<SkillCourseAggregateDocument>([
      {
        $lookup: {
          from: 'courses',
          let: { skillName: '$name' },
          pipeline: [
            {
              $match: {
                $expr: {
                  $in: ['$$skillName', '$skills'],
                },
              },
            },
            { $match: queryFilter },
          ],
          as: 'courses',
        },
      },
    ]);



โ€ฆcreates a tight coupling between the skills(inside global microservice)and

courses domains by assuming internal schema knowledge and exposing cross-context joins. This breaks the principle of encapsulation and introduces hidden dependencies that make services harder to evolve independently.

Domain
Profile
Action
refactor
Department
Backend

Please authenticate to join the conversation.

Upvoters
Status

Completed

Board
๐Ÿ’ก

Feature Request

Date

11 months ago

Author

[Deleted User]

Subscribe to post

Get notified by email when there are changes.