UpsertGraph Update Rows Based On Different Column Than 'id'
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.
EDIT
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?
Answer
Nope.
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.
REF: https://vincit.github.io/objection.js/guide/query-examples.html#graph-upserts
Its mentioned that default functionality can be modified but modifying the search based on different column than id
is not possible.
Related Questions
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM