Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong documentation for cds.foreach #1499

Open
kulliax opened this issue Dec 5, 2024 · 3 comments · May be fixed by #1549
Open

wrong documentation for cds.foreach #1499

kulliax opened this issue Dec 5, 2024 · 3 comments · May be fixed by #1549
Assignees

Comments

@kulliax
Copy link

kulliax commented Dec 5, 2024

The documentation describes a behaviour that is not implemented:

Executes the statement and processes the result set row by row. Use this API instead of [`cds.run`](#srv-run-query) if you expect large result sets. Then they're processed in a streaming-like fashion instead of materializing the full result set in memory before processing.

comment in source:

node_modules/@sap/cds/lib/srv/srv-api.js
/**

  • Streaming API variant of .run(). Subclasses should override this to support real streaming.
  • The default implementation doesn't stream, but simply invokes the callback on each row.
  • The callback function is invoked with (row, index).
    */

Does this mean that we have to implement this ourselves? I can't find a subclass for this or is that nearly planned? We've come across this point several times and after the big release of the revised documentary we wanted to address it here as well.

For example, the hana with the stream module actually supports this function.

@renejeglinsky
Copy link
Contributor

Hi @kulliax ,
thanks for opening this issue and sorry for the late response.

@sjvans Could you check this feedback if that is not implemented or if we didn't describe it well enough? Thanks.

@sjvans sjvans linked a pull request Jan 8, 2025 that will close this issue
@sjvans
Copy link
Contributor

sjvans commented Jan 8, 2025

correct, it is not yet implemented by any subclass (cds.DatabaseService, mainly). i'll try to clarify that. the implementation in cds.Service itself is there to ensure the API and will/ must always remain a mock.

https://cap.cloud.sap/docs/node.js/core-services#how-to-provide-custom-service-implementations documents how to provide custom service implementations. the BooksService in that example could have a foreach function that overrides the non-streaming default impl provided by CAP.

@kulliax
Copy link
Author

kulliax commented Jan 14, 2025

Hi @sjvans as I heard in one of the last roundtables, you have it on the list. Is there a roadmap for it somewhere?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants