Constructors

Methods

  • Calculate review statistics for a single target

    Parameters

    • targetId: string
    • target: "user" | "organization"

    Returns Promise<ReviewStatistic>

    Promise

    Description

    This function will calculate the average rate, average sub rates and total count of reviews for a single target.

    Algorithm:

    1. Match all reviews with the targetId and target
    2. Split into two aggregation pipelines for total stats and sub rates stats

    Total stats:

    1. Group by null to get the average rate and total count

    Sub rates stats:

    1. Project the sub rates into an array
    2. Unwind the array
    3. Group by the sub rate key to get the average of each sub rate
    4. Group by null to get the average sub rates as an array
    5. Replace root to merge the average sub rates array into an object
  • Create review into database

    Parameters

    • review: Omit<ReviewBase, "isDeleted" | "targetId"> & WithCustomFields & {
          targetId: string;
      }

    Returns Promise<{
        id: string;
    }>

    Promise<{id: string}> id of created review record

  • Get review list from database

    Parameters

    • Optional opts: {
          filterExpression?: Expression;
          orderParams?: OrderParam<string>[];
          pagination?: PaginationOptions;
      }
      • Optional filterExpression?: Expression
      • Optional orderParams?: OrderParam<string>[]
      • Optional pagination?: PaginationOptions

    Returns Promise<PaginatedFindResult<ReviewEntity>>

    paginated review list query result

Properties

db: Db
endpoint: string
reviewRepository: MongoRepository<ReviewEntity>
COLLECTION_REVIEW: "reviews" = 'reviews'

Generated using TypeDoc