add arango package with aql generation

This commit is contained in:
Aneurin Barker Snook
2023-10-07 10:23:02 +01:00
commit fa4f403c46
5 changed files with 198 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
package arango
import (
"regexp"
)
// https://docs.arangodb.com/3.11/aql/fundamentals/bind-parameters/#syntax
var paramRegexp = regexp.MustCompile("@{1,2}([A-z0-9_]+)")
// ReadParams reads out named parameters from an AQL string.
func ReadParams(input string) []string {
params := []string{}
matches := paramRegexp.FindAllStringSubmatch(input, -1)
if matches != nil {
for _, match := range matches {
params = append(params, match[1])
}
}
return params
}