#How to iterate over entire table?

1 messages · Page 1 of 1 (latest)

keen trellis
#

I am trying to iterate over the entire product table, in order to create variants for it, like this:

  let productList = await productService.listAndCount(
    {},
    { skip: skip, take: 20 }
  );

Where skip is an incrementing (+20 each iteration) value. My impression is that this would go through the entire products table, grab 20 rows, process them, etc, etc.

However I seem to be getting duplicates sometimes of products that I already have grabbed... is there a reason for this? Is there a way to avoid this?

hardy sedge
#

You are taking 20 prod randomly. You need to add an order

#

For example ordering by created at

keen trellis