remove product attribute
This commit is contained in:
@@ -1,30 +1,28 @@
|
||||
import type { EntityManager } from '@mikro-orm/core';
|
||||
import { Attribute } from 'src/modules/product/entities/attribute.entity';
|
||||
import { attributeValueData } from './data/attribute-value.data';
|
||||
import { AttributeValue } from 'src/modules/product/entities/attribute-value.entity';
|
||||
// import type { EntityManager } from '@mikro-orm/core';
|
||||
// import { attributeValueData } from './data/attribute-value.data';
|
||||
|
||||
// export class AttributeValueSeeder {
|
||||
// async run(
|
||||
// em: EntityManager,
|
||||
|
||||
export class AttributeValueSeeder {
|
||||
async run(
|
||||
em: EntityManager,
|
||||
// ): Promise<void> {
|
||||
// const attributes = await em.findAll(Attribute)
|
||||
// for (const attr of attributes) {
|
||||
|
||||
): Promise<void> {
|
||||
const attributes = await em.findAll(Attribute)
|
||||
for (const attr of attributes) {
|
||||
// const attrValues = attributeValueData.filter(a => a.attributeName === attr.name)
|
||||
|
||||
const attrValues = attributeValueData.filter(a => a.attributeName === attr.name)
|
||||
|
||||
for (const av of attrValues) {
|
||||
// for (const av of attrValues) {
|
||||
|
||||
const a= em.create(AttributeValue, {
|
||||
value: av.value,
|
||||
attribute: attr
|
||||
});
|
||||
// const a= em.create(AttributeValue, {
|
||||
// value: av.value,
|
||||
// attribute: attr
|
||||
// });
|
||||
|
||||
em.persist(a)
|
||||
}
|
||||
// em.persist(a)
|
||||
// }
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
await em.flush();
|
||||
}
|
||||
}
|
||||
// await em.flush();
|
||||
// }
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user