on 2024 Oct 30 8:43 AM
Hi,
does anyone have a working example of cds.foreach? I always get error messages that it is a query3 and not query2.
Docu: https://cap.cloud.sap/docs/node.js/core-services#srv-foreach-entity
Request clarification before answering.
The solution:
cds.foreach(cds.parse.cql("SELECT ID FROM db_table"), (each: table) => console.log(each.ID))
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @akuller ,
Is it possible that maybe you missed a single quote (') around your entity name?
Could you try it in the following way:
SELECT.from('Requests')
Regards,
Peter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @akuller , it works for me. I just tried with the Standalone CDI with @cap-js/cds-typer 0.4.0. I receive no type error and no runtime error, foreach just runs with no problem.
Hi @catano
The query is based on the example from the docu: https://cap.cloud.sap/docs/node.js/core-services#srv-foreach-entity
@cap-js/asyncapi: 1.0.2
@cap-js/cds-typer: 0.28.0
@cap-js/cds-types: 0.7.0
@cap-js/db-service: 1.14.1
@cap-js/hana: 1.4.0
@cap-js/openapi: 1.0.7
@cap-js/sqlite: 1.7.5
@cap-js/telemetry: 1.0.1
@sap/cds: 8.4.0
@sap/cds-compiler: 5.4.0
@sap/cds-dk: 8.4.0
@sap/cds-dk (global): 8.3.0
@sap/cds-fiori: 1.2.7
@sap/cds-foss: 5.0.1
@sap/cds-mtxs: 2.3.0
@sap/eslint-plugin-cds: 3.1.1
Node.js: v20.12.0
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
30 | |
21 | |
16 | |
8 | |
7 | |
6 | |
5 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.