dbg()
Output a message in the query response and return the message.
Description
The dbg()
(debug) method outputs message in the
summary of query responses and
returns message in the query result. In the summary, debug messages are
annotated as info
.
dbg()
and log()
You can use dbg()
inline within method calls
for debugging.
Debug message template
The debug message template is:
info: <message>
at *<source>*:<line>:<column>
|
<line> | dbg(<message>)
| ^^^^^^^^^^^
|
where:
Field | Description | ||||||
---|---|---|---|---|---|---|---|
|
Message source.
|
||||||
|
Line number where |
||||||
|
Character offset in |
||||||
|
String-serialized |
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
message |
Yes |
Value to output to the query summary and query results. |
Examples
-
Output a composed value in the query response:
Product.create({ name: "debug1", stock: dbg(1 + 2 + 3), })
info: 6 at *query*:3:13 | 3 | stock: dbg(1 + 2 + 3), | ^^^^^^^^^^^ | { id: "394873023799230528", coll: Product, ts: Time("2099-04-11T12:38:31.050Z"), name: "debug1", stock: 6 }
-
Output a Struct:
Product.create( dbg({ name: "debug2", stock: 1 + 2 + 3, }) )
info: { name: "debug2", stock: 6 } at *query*:2:6 | 2 | dbg({ | ______^ 3 | | name: "debug2", 4 | | stock: 1 + 2 + 3, 5 | | }) | |____^ | { id: "394873104675897408", coll: Product, ts: Time("2099-04-11T12:39:48.180Z"), name: "debug2", stock: 6 }
-
Output a Document:
dbg( Product.create({ name: "debug3", stock: 1 + 2 + 3, }) )
info: { id: ID("394873211262599234"), coll: Product, ts: TransactionTime(), name: "debug3", stock: 6 } at *query*:1:4 | 1 | dbg( | ____^ 2 | | Product.create({ 3 | | name: "debug3", 4 | | stock: 1 + 2 + 3, 5 | | }) 6 | | ) | |_^ | { id: "394873211262599234", coll: Product, ts: Time("2099-04-11T12:41:29.835Z"), name: "debug3", stock: 6 }
Is this article helpful?
Tell Fauna how the article can be improved:
Visit Fauna's forums
or email docs@fauna.com
Thank you for your feedback!