on 2022 Jan 14 10:33 PM
Hi everyone,
I have a problem with run cql queries in custom endpoints in a muntitenant scenario, I followed the next example for create a custom endpoints to response in json format, works fine in an single tenant scenario, but when I tried take it a multitenant I got the next error:
There is no instance for tenant "anonymous"
I tried with the instructions cds.run() and tx.run() but none worked for me.
I would appreciate if someone could help me
Request clarification before answering.
Hi Johan,
The tenant information is stored in the req object: https://cap.cloud.sap/docs/node.js/events#cds-request. You should provide this information to your transaction: https://cap.cloud.sap/docs/node.js/transactions. Something like
const tx = cds.tx(req)
OR
const tx = cds.tx({ user: new cds.User({ id: 'user', tenant }) })
AND THEN
const rs = await tx.run('...')
Best regards,
Vitaly
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vitaly,
actually I tried to do the following:
let db = await cds.connect.to('db');
const tx = db.tx();
and the following also:
const tx = cds.tx(req);
but what really worked for me was the following:
const tx = cds.tx({
user: req.authInfo.getEmail(),
tenant: req.authInfo.getSubaccountId()
});
I don't know the reason why the above statements didn't work, I'm very grateful to you Vitaly
User | Count |
---|---|
81 | |
30 | |
10 | |
8 | |
8 | |
7 | |
6 | |
6 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.