🚨 Announcement: A New Chapter for Vendure read more

FastImporterService

FastImporterService

A service to import entities into the database. This replaces the regular create methods of the service layer with faster versions which skip much of the defensive checks and other DB calls which are not needed when running an import. It also does not publish any events, so e.g. will not trigger search index jobs.

In testing, the use of the FastImporterService approximately doubled the speed of bulk imports.

Signature

class FastImporterService {
  async initialize(channel?: Channel) => ;
  async createProduct(input: CreateProductInput) => Promise<ID>;
  async createProductOptionGroup(input: CreateProductOptionGroupInput) => Promise<ID>;
  async createProductOption(input: CreateProductOptionInput) => Promise<ID>;
  async addOptionGroupToProduct(productId: ID, optionGroupId: ID) => ;
  async createProductVariant(input: CreateProductVariantInput) => Promise<ID>;
}

Members

initialize

async method
type:
(channel?: Channel) =>

This should be called prior to any of the import methods, as it establishes the default Channel as well as the context in which the new entities will be created.

Passing a channel argument means that Products and ProductVariants will be assigned to that Channel.

createProduct

async method
type:
(input: CreateProductInput) => Promise<ID>

createProductOptionGroup

async method
type:
(input: CreateProductOptionGroupInput) => Promise<ID>

createProductOption

async method
type:
(input: CreateProductOptionInput) => Promise<ID>

addOptionGroupToProduct

async method
type:
(productId: ID, optionGroupId: ID) =>

createProductVariant

async method
type:
(input: CreateProductVariantInput) => Promise<ID>