GROQ
GROQ copied to clipboard
Extra function suggestions.
Hey 👋
I would like to suggest some functions to add to the GROQ queries if possible. I would love to add them myself, but not sure how or where to start. I have managed to create one by chaining the existing functions, but for the others I require functions that don't exists.
My suggestions are:
// truncate a string to N chars
string::truncate(string, number)
// Extra rounding functions
math::floor(number)
math::ceil(number)
// Convert/coherse string into a number - Not sure how to implement to float or int (Maybe a flag)
number(string)
// or:
number::int(string)
number::float(string)
Currently I am truncating a string with array::join(string::split((pt::text(body)), "")[0..255], "") which is not ideal 😬
For reference to create a floor() I am using string::split(string(myNumber), ".")[0] which works, but returns a string, not a number. I can't make a ceil() alternative because I need the result of the floor as a number so that I can add 1 to the resulting value. I'm open to any suggestions or ideas to get around this 😄