【问题标题】:How can I print an FQL query from JavaScript as a string (e.g. to test it in the Fauna shell)?如何将 JavaScript 中的 FQL 查询打印为字符串(例如,在 Fauna shell 中对其进行测试)?
【发布时间】:2021-10-07 04:03:30
【问题描述】:

FQL 查询在 JS 中构造为对象。出于调试目的,如何将这些对象之一打印为字符串查询?例如:

q.Get(q.Ref(q.Collection("Patterns"), req.params.id))

我想知道这个生成的FQL字符串,比如:

Get(Ref(Collection("Patterns"), "300223720476116480"))

【问题讨论】:

    标签: faunadb


    【解决方案1】:

    您可以将toFQL 方法用于Expr 类。

    const expr = q.Get(q.Ref(q.Collection("Patterns"), "1234"))
    
    console.log(expr.toFQL())
    

    【讨论】:

    • 谢谢!这个方法好像没有暴露在Expr的类型声明中,所以没注意。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-28
    • 1970-01-01
    • 2011-08-02
    • 2021-12-02
    • 1970-01-01
    相关资源
    最近更新 更多