You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mongodb command line client supports specifying fields without quotes:
{foo: "bar"} can be used instead of: {"foo": "bar"}
I'm wondering whether this idea could be used in nimongo/bson to simplify BSON construction, using an appropriate macro that would understand untyped params
simplified example
import macros
macrofoo(bar: untyped): untyped=let temp =repr(bar)
result=quotedo:
var ret =""
ret.addQuoted `temp`
ret
echofoo(hello_world) # prints: "hello_world"echofoo(helloWorld) # prints: "helloWorld"
note
obviously, this would only be used for fields that are valid symbols
let doc = toBsonMagicFields{
foo1: "bar1",
"foo2-special", "bar2", # here, we can't use foo2-special, "bar2"
}
note
note that toBsonMagicFields would ignore variables in scope for the "key" positions of each field definition, eg:
mongodb command line client supports specifying fields without quotes:
I'm wondering whether this idea could be used in nimongo/bson to simplify BSON construction, using an appropriate macro that would understand untyped params
simplified example
note
obviously, this would only be used for fields that are valid symbols
note
note that
toBsonMagicFields
would ignore variables in scope for the "key" positions of each field definition, eg:The text was updated successfully, but these errors were encountered: