Category service

Constructors

Methods

  • Delete category from database by Id Process of deleting a category:

    • Confirm if category in database, if not, throw not found error
    • Update the records, with category id inside the ancestors, pull categoryId from ancestors
    • Update the records, with parentId = categoryToDelete.id, set parentId=categoryToDelete.parentId If category tree looks like A-B-C-D-E, after delete B, it will become A-C-D-E If category tree looks like A-B, after delete A, it will become B

    Parameters

    • id: string

    Returns Promise<boolean>

  • Return two layer category tree. category object with a children property, which is a categoryList

    Parameters

    • parentId: string

      parentId of a categoryTreeList

    • orderParams: OrderParam<string>[]
    • paginationOptions: PaginationOptions

    Returns Promise<PaginatedFindResult<CategoryTree>>

    categoryTree blocks-6a17

  • Update category data. If category parentId is updated, all the location have this category id in path, will get updated.

    Parameters

    • id: string

      blocks-9132

    • categoryInfo: Partial<Omit<Category, "id">>

    Returns Promise<{
        id: string;
    }>

Properties

categoryRepository: MongoRepository<CategoryEntity>
db: Db
COLLECTION_CATEGORY: "categories" = 'categories'

Generated using TypeDoc