DEV Community

Cover image for Announcing new FQL features
Fauna for Fauna, Inc.

Posted on • Updated on • Originally published at fauna.com

Announcing new FQL features

Author: Lewis King
Date: December 5, 2019
Originally posted on the Fauna blog.

--

We’re pleased to announce new FQL capabilities that empower users to write more concise and powerful FQL statements with:

  • Date/Time arithmetic functions
  • Any/All functions
  • Type cast functions
  • Type check functions

New preview features

Please note that these new functions are currently in Preview mode, which means that they will be fully supported in the JVM and JS drivers only and will continue to improve over the next 2 months. We invite you to send us feedback about their use. To learn more, please check out our documentation.

Date/Time arithmetic functions

The following Date/Time arithmetic functions have been implemented:

TimeAdd(), TimeSubtract(), and TimeDiff()

TimeAdd(Date("1970-01-01"), 1, "day")
TimeSubtract(Time("1970-01-01T00:00:00Z"), 10, "minutes")
TimeDiff(Date("1970-01-01"), Date("1970-01-02"), "days")
Enter fullscreen mode Exit fullscreen mode

Any() and All() functions

Any() and All() reduce their parameter to a boolean: are any items true, or are all items true, respectively. They work like Or() and And() but for sets, arrays, and pages.

Unlike the existing boolean functions, Any() and All() have default values for empty inputs. (Any([]) returns false, and All([]) returns true).

Any(Map(Paginate(Match("user_ages_by_name", "Alice")), Lambda("age", GTE(Var("age"), 18)))
Enter fullscreen mode Exit fullscreen mode

Type cast functions

The following type casting functions have been implemented:

ToDouble, ToArray, ToObject, and ToInteger

ToDouble(1) => 1.0
ToInteger(3.14) => 3
ToArray({x: 10, y: 20}) => [["x", 10], ["y", 20]]
ToObject([["x", 10], ["y", 20]]) => {x: 10, y: 20}
Enter fullscreen mode Exit fullscreen mode

Type check functions

The following type check functions have been implemented:

IsNumber, IsDouble, IsInteger, IsBoolean, IsNull, IsBytes, IsTimestamp, IsDate, IsString, IsArray, IsObject, IsRef, IsSet, IsDoc, IsLambda, IsCollection, IsDatabase, IsIndex, IsFunction, IsKey, IsToken, IsCredentials, and IsRole

An example of one of these in use:

IsDouble(3.14) => true
Enter fullscreen mode Exit fullscreen mode

New GA Features

We’re excited to announce that the new FQL functions that we released in Preview mode back in September are now generally available. This means that the functions are now also available in our Go, C#, and Python drivers. It also means that these functions are part of the FQL core product and you can expect them to be fully reliable.

New GA functions include Range, Reduce, Format, and Merge.

Conclusion

With our latest FaunaDB update, users now have access to new FQL functionality including date arithmetic and type cast and check functions.

These methods are in Preview! So please let us know what you think so that we can incorporate feedback into the formal release, and visit our documentation to learn more.

What other functions would you like to see implemented in FaunaDB? Please reach out to me on our Community Slack and describe any other features that would make FaunaDB an obvious choice for your next project.

Top comments (0)