2
votes

How would one translate the following composite key query:

?stale=false&connection_timeout=60000&limit=10&skip=0&startkey=["Default",{}]&endkey=["Default"]&descending=true

to couchbase .net api when using F#. I found a similar using C# LINQ here Couchbase .Net Library complex startKey/endKey types, but how can I accomplish the same using F#?

The missing parts are the ???

let result = myView.Descending(true).Stale(StaleMode.False).Limit(limit).StartKey( ??? ).EndKey( ??? )

Any help would be appreciated.

1

1 Answers

2
votes

It appears that you're asking how to create an array in F#. To declare an object array in F# do this:

let (startKey: Object array) = [|35; 23; new Object()|]
let (endKey: Object array) = [|35; 23|]

Note that normally the type specification isn't needed, but since you're mixing types in the array, the compiler will assume the type of the first object in the array (int) and so the new Object() would cause a compile error. Adding the type specification fixes that issue.

let result = myView.Descending(true).Stale(StaleMode.False).Limit(limit).StartKey( startKey ).EndKey( endKey )