Skip to content

Commit

Permalink
add include
Browse files Browse the repository at this point in the history
  • Loading branch information
bahram1249 committed Jun 28, 2024
1 parent 5d03dc3 commit fd680f0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { ProductCommentStatusEnum } from '@rahino/ecommerce/util/enum/product-co
import { SCORE_COMMENT_JOB, SCORE_COMMENT_QUEUE } from './constants';
import { InjectQueue } from '@nestjs/bullmq';
import { Queue } from 'bullmq';
import { ECProduct } from '@rahino/database/models/ecommerce-eav/ec-product.entity';

@Injectable()
export class ProductCommentService {
Expand Down Expand Up @@ -59,6 +60,12 @@ export class ProductCommentService {
as: 'status',
required: false,
},
{
attributes: ['id', 'title', 'sku'],
model: ECProduct,
as: 'product',
required: false,
},
{
attributes: ['id', 'firstname', 'lastname'],
model: User,
Expand Down Expand Up @@ -128,6 +135,12 @@ export class ProductCommentService {
as: 'status',
required: false,
},
{
attributes: ['id', 'title', 'sku'],
model: ECProduct,
as: 'product',
required: false,
},
{
attributes: ['id', 'firstname', 'lastname'],
model: User,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { EAVEntity } from '../eav/eav-entity.entity';
import { ECProductCommentStatus } from './ec-comment-status.entity';
import { User } from '../core/user.entity';
import { ECProductCommentFactor } from './ec-product-comment-factor.entity';
import { ECProduct } from './ec-product.entity';
@Table({ tableName: 'ECProductComments' })
export class ECProductComment extends Model {
@Column({
Expand All @@ -23,11 +24,11 @@ export class ECProductComment extends Model {
type: DataType.BIGINT,
allowNull: true,
})
@ForeignKey(() => EAVEntity)
@ForeignKey(() => ECProduct)
entityId?: bigint;

@BelongsTo(() => EAVEntity, { as: 'entity', foreignKey: 'entityId' })
entity?: EAVEntity;
@BelongsTo(() => ECProduct, { as: 'product', foreignKey: 'entityId' })
product?: ECProduct;

@Column({
type: DataType.INTEGER,
Expand Down

0 comments on commit fd680f0

Please sign in to comment.