Dedicated atlas instance :: collation is not a function error

Hi Team,

I have a dedicated cluster with M10 facing issue with server-less function unable to call a collation index with case insensitive:
context.service.getDb(“”).getCollection(“”).find( {name: { $regex:“kish”, $options: “i” } }).collation({locale: “en_US”})

Getting the following error:
{“error”:“{"message":"‘collation’ is not a function","name":"TypeError"}”,“error_code”:“FunctionExecutionError”,“link”:“App Services<>/apps/<>/logs?co_id=<>”}

Please help what did i miss? Is the Collation index function does not work in Server-less function as well ?

Hi @RamaKishore_K ,

Is the Collation index function does not work in Server-less function as well ?

That’s indeed the case: collation(…) is a method for a cursor, and the find(…) version in Functions returns a limited version of it. Overall, the set of the API available to Functions is trimmed down, and the details are documented on the specific App Services’ page.

You may be able to use a form of collation as query option (as opposed to a function) when running the function as System, however.

Hi @Paolo_Manna ,

I have used options in find method and applied collation index, it worked.

Thank you.