UpsertGraph Update Rows Based On Different Column Than 'id'

- 1 answer

I have a products table with id and supplier_id columns.

How do I make upsertGraph update rows based on supplier_id instead of id when I fetch products from supplier?

Now upsertGraph only uses insert because there is no id property present.


I fetch product lists from several different suppliers containing id, name, price

I store products in my database with id, name, price and supplier_id

Therefor I'm trying to make upsertGraph update/insert based on supplier_id, to update products based on supplier_id instead of id.

Is this possible?




Well what you want is not possible with upsertGraph as the official docs states

By default upsertGraph method updates the objects that have an id, inserts objects that don't have an id and deletes all objects that are not present. This functionality can be modified in many ways by providing UpsertGraphOptions object as the second argument.


Its mentioned that default functionality can be modified but modifying the search based on different column than id is not possible.