Info pertaining to native FQL will largely be omitted for conciseness, refer to the native FQL docs for more info regarding native FQL.
createPrefixSearchResources( client )( config )Idempotently creates Collections and Indexes for prefix searching. Prefix searching is particularly useful for querying geohashes.
// REQUIRED
const client = new faunadb.Client({secret: "<FAUNAD_SECRET>"})// REQUIRED
{
// OPTIONAL
minPrefixLength: 1, // default
// OPTIONAL
maxPrefixLength: 100, // default
// REQUIRED
// very similar to Select's path arg, except a Collection name is required.
prefix_field_locations: ["<Collection_Name>.<Field_A>...<Field_B>"]
}Doesn't return anything. However, it does console.log the results of all client.query executions, along with step-by-step progress.
BulkCreate( CollectionRef, dataArray )Loops over dataArray and creates dataArray.length documents in CollectionRef. Refer to the source code for more info, it's very straightforward.
// REQUIRED
q.Collection("<COLLECTION_NAME>")// REQUIRED
[
// data for document 1
{
any_field: "any_value"
},
// ...
// data for document N
{
any_field: "any_value"
}
]An object containing the metadata about the last Create (on CollectionRef) operation used under the hood.
SelectDeep( pathsArray, DocumentRef )Loops through pathsArray, which represents nested Documents, and resolves each array with Select and Get.
// REQUIRED
[
["data", "nested_document_ref"],
["data", "some_field"]
]// REQUIRED (many ways to do this)
q.Ref(q.Collection("<COLLECTION_NAME>"), "<DOCUMENT_ID>")The results of the final Get called.
CreateNGramSearchIndex( param_object )Creates an Index with an N-Gram binding. Inherits the same constraints that CreateIndex has, since it uses CreateIndex under the hood. An N-Gram, or at least how it's implemented in FQL (NGram, FYI it's undocumented; refer to the community slack and/or FaunaDB blog for more info), offers similar behavior to a substring search algorithm.
Is an extension of CreateIndex's param_object. Documented below is only what is unique to CreateNGramSearchIndex.
{
// REQUIRED
// identical to how the native FQL Select handles pathing
// e.g. ["data", "some_field"]
fieldSelectPath: ["field1", ..., "fieldN"],
// OPTIONAL
// must be >= 0
minGramLength = 1
maxGramLength = 100
// some requirements
...restOfCreateIndexParams
}An object containing the metadata about the CreateIndex operations used under the hood.
CreatePrefixSearchIndex( param_object )Creates an Index with maxPrefixLength - minPrefixLength term bindings. Inherits the same constraints that CreateIndex has, since it uses CreateIndex under the hood. Prefix search is particularly useful for querying geohashes.
Is an extension of CreateIndex's param_object. Documented below is only what is unique to CreatePrefixSearchIndex.
{
// REQUIRED
// identical to how the native FQL Select handles pathing
// e.g. ["data", "some_field"]
fieldSelectPath: ["field1", ..., "fieldN"],
// OPTIONAL
// must be >= 0
minPrefixLength = 1
maxPrefixLength = 100
// some requirements
...restOfCreateIndexParams
}An object containing the metadata about the CreateIndex operations used under the hood.
MultiMatch( IndexRef, searchTerms )Maps over searchTerms and returns a Union of searchTerms.length Match(Index(...), ...) calls.
// REQUIRED
q.Index("<INDEX_NAME>")// REQUIRED
[
"Term_1",
//...
"Term_N"
]A Union of searchTerms.length Match(Index(...), ...) calls.
Characters( string )Applies NGram to the provided string, with parameters set to produce n-grams of length 1. e.g. "Cat" returns ["C", "a", "t"].
// REQUIRED
"wow I'm a string"An array of length-1 n-grams. e.g. "Cat" returns ["C", "a", "t"].
NGramGenerator( string, minGramLength = 1, maxGramLength = 100 )Creates string n-grams of length minGramLength to maxGramLength. NGram is used under the hood of course.
// REQUIRED
"wow I'm a string"// OPTIONAL
minGramLength = 1 // default// OPTIONAL
maxGramLength = 100 // defaultAn array of n-grams, ranging from minGramLength to maxGramLength inclusively, in size.
StringIndexRange( string, indexRange = [0, 100] )Provides an array range of increasing integers, to mimic a string's indexes. Currently, it's impossible to do such a thing entirely in FQL, thus the array is created on the client-side in JavaScript.
// REQUIRED
"wow I'm a string"// OPTIONAL
indexRange = [0, 100] // defaultReturns an array of increasing integers (increasing by 1) from indexRange[0] to string.length (or indexRange[1], whichever is greater).
StringPrefixGenerator( string, minPrefixLength = 1, maxPrefixLength = 100 )Creates string prefixes of length minPrefixLength to maxPrefixLength. A prefix is essentially a substring that has to start from the beginning of a string.
// REQUIRED
"wow I'm a string"// OPTIONAL
minPrefixLength = 1 // default// OPTIONAL
maxPrefixLength = 100 // defaultAn array of prefixes, ranging from minPrefixLength to maxPrefixLength inclusively, in size.