0

I'm a newbie to FaunaDB. I've been able to add a bunch of documents to a collection using C# like this:

Value value = fauna.Query(Create(
    Collection("MyCollection"),
    Obj("data", Encoder.Encode(trans))
    )).Result;

Now I need to query individual documents. So in the FaunaDB Shell, this works great and returns the expected document.

Get(
  Match(
    Index("FITID"),
    "2021043000000000000000000000002122180019216600000088701"
  )
)

However, when I try to use this in C#, I get an error that I can't figure out how to fix. I can't find any examples specific to what I'm trying to do.

Value value = fauna.Query(
        Get(
            Match(
                Index("FITID", "2021043000000000000000000000002122180019216600000088701")
                )
            )
        ).Result;

The error I'm getting is

BadRequest: invalid argument: Database Ref expected, String provided.

Any suggestions?

EDIT: Thanks to @eskwayrd for spotting my error. The correct command is below.

Value value = fauna.Query(
        Get(
            Match(
                Index("FITID"), "2021043000000000000000000000002122180019216600000088701"
                )
            )
        ).Result;

1 Answer 1

1

The Index function returns a reference for the specified index name. In your C# code, you are passing both the index name and the numeric string to Index. If you fix the brackets in your query, it should work just fine.

See the second example under "Retrieve Posts": https://docs.fauna.com/fauna/current/tutorials/crud?lang=csharp#retrieve

Sign up to request clarification or add additional context in comments.

1 Comment

It's always the most obvious things that I can't see. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.