Skip to content
Discussion options

You must be logged in to vote

@iammrsea I got the same problem today and solved it !
I think in your code you return the object/Model Product, and not the serialized version like you think it was in your post.
When I have an array of object, I do this :
await Event.fetchOrCreateMany('event_id', arrayEvent.map(ev => ev.toJSON()))

So in your code, I think you should write :

const products = payment.order.products.map((product) => {
      product.availableQty = product.availableQty - product.qty_bought;
      return product;
    });
    await Product.updateOrCreateMany("id", products.map(prod => prod.toJSON()));

OR

    const serialized_products = payment.order.products.map((product) => {
      product.availableQty = pro…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
3 replies
@iammrsea
Comment options

@KWINGLION
Comment options

@iammrsea
Comment options

Comment options

You must be logged in to vote
1 reply
@iammrsea
Comment options

Answer selected by iammrsea
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
4 participants