SAP CAP Blog Posts
cancel
Showing results for 
Search instead for 
Did you mean: 
qmacro
Developer Advocate
Developer Advocate
869

The cds REPL is a powerful facility that helps us explore and debug. It's based on the regular Node.js REPL, which has a number of REPL-level commands:

; node
Welcome to Node.js v24.15.0.
Type ".help" for more information.
> .help
.break    Sometimes you get stuck, this gets you out
.clear    Alias for .break
.editor   Enter editor mode
.exit     Exit the REPL
.help     Print this help message
.load     Load JS from a file into the REPL session
.save     Save all evaluated commands in this REPL session to a file

Press Ctrl+C to abort current expression, Ctrl+D to exit the REPL

The cds REPL extends the Node.js REPL with various commands, two of which have been available for a good while:

.inspect   Sets options for util.inspect, e.g. `.inspect .depth=1`.
.run       Runs a cds server from a given CAP project folder, or module name like @capire/bookshop.

Recently (in a CAP release earlier this year) the cds REPL gained a new "query mode" command, which enables us to write queries directly. In other words, instead of this:

> await cds.ql`SELECT from Books {title, price}`

we can, within the new query mode, write simply:

cql> select from Books {title, price}

What is the cds REPL command to enter this new query mode?

This is a question from the June Developer Challenge on CAP Knowledge. And don't forget: always submit your answer as a hash, on its own - read the Taking part section of the intro post for more info. At the end of today, this question will be updated with links to further reading on this topic.

Further info:

30 Comments