It would be very handy if edgedb-net supported passing in a Some type in query parameters.
Since the edgedb-net client doesn't support passing in Some values, I have to manually unwrap the optionals to get the value or set them to null. Since you can already pass in a None value as a parameter, it would make things a lot simpler if you could also pass in a Some value too. That would mean I wouldn't have to unwrap them or set them to null.
A somewhat contrived example:
This doesnt work:
let getSinglePost (postId: string option) =
let queryParams = new Dictionary<string, obj>()
queryParams.Add("postId", postId)
task {
try
let! results =
dbClient.QuerySingleAsync<Post>(
"select Post{*} filter .postId = <optional str>$postId",
queryParams
)
return Ok(results)
with err ->
Logger.Error(message = "Error with getSinglePost", error = err)
return Error err
}
So I have to do:
let getSinglePost (postId: string option) =
let pId = Option.defaultValue null postId
let queryParams = new Dictionary<string, obj>()
queryParams.Add("postId", pId)
task {
try
let! results =
dbClient.QuerySingleAsync<Post>(
"select Post{*} filter .postId = <optional str>$postId",
queryParams
)
return Ok(results)
with err ->
Logger.Error(message = "Error with getSinglePost", error = err)
return Error err
}
It would be very handy if edgedb-net supported passing in a
Some
type in query parameters.Since the edgedb-net client doesn't support passing in
Some
values, I have to manually unwrap the optionals to get the value or set them to null. Since you can already pass in aNone
value as a parameter, it would make things a lot simpler if you could also pass in aSome
value too. That would mean I wouldn't have to unwrap them or set them to null.A somewhat contrived example: This doesnt work:
So I have to do: