cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Upsert Operation in CAP NodeJS

0 Kudos
4,340

Hi All,

I have a requirement to upsert (update if key exists, if not insert) into HANA DB using NodeJS API for CAP. Of the below APIs, which can be used:

If the above APIs do not satisfy, which one to use?

Thanks & Regards,

Harish

Accepted Solutions (1)

Accepted Solutions (1)

OlenaT
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Harish,

Thank you for the clarification, for the upsert you can use the following API:

srv/tx.update (entity, key?) .with? (data) … → query

It will update the existing data or insert the missing one.

Best regards,

Olena

Jani_Basha_Shaik
Discoverer
0 Kudos
Hi Olena,
Jani_Basha_Shaik
Discoverer
0 Kudos
Hi Olena, Is it works on bulk upsert or for single record ?

Answers (1)

Answers (1)

OlenaT
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

Could you please explain what are you trying to achieve in more details? Do you want to insert data into composition child or do you want to change a references to association target? There is no Deep Insert for Associations. You can read more about Deep Insert here: https://cap.cloud.sap/docs/guides/providing-services#serving-document-data

Best regards,

Olena

0 Kudos

Hi olena_ ,

We are calling SuccessFactors api to get workflow related information in our CAP HANA DB. Some of the data retrieved from the service can be old but updated, whereas some may be new. If it already exists in HANA DB, it should update, else insert.

Thanks,

Harish