We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have the following code:
lanprops = [] for lan in languages # NOTE: OrderedDict gives error in Mongoc.BSON() prop = OrderedDict{String, Any}() prop["hasPropertyName"] = "hasLabel" prop["hasDataType"] = "string" prop["hasSpecifier"] = "language: " * lan push!(lanprops, prop) end initdoc = Dict{String, Any}() initdoc["_id"] = "itemType" initdoc["hasBaseType"] = "systemItem" initdoc["hasProperties"] = lanprops Mongoc.transaction(client) do session new_item = Mongoc.BSON(initdoc) push!(collection, new_item) end
The OrderedDict gives the following error:
Error: ERROR: │ exception = │ MethodError: no method matching setindex!(::Mongoc.BSON, ::OrderedCollections.OrderedDict{String, Any}, ::String)
When I change the OrderedDict to a ‘regular’ Dict everything works fine. What can I do to make the OrderedDict working okay in Mongoc.BSON()?
The end result must look like this (the order of the key-value pairs under hasProperties is important):
{ "_id" : "itemType", "hasBaseType" : "systemItem", "hasProperties" : [{ "hasPropertyName" : "hasLabel", "hasDataType" : "string", "hasSpecifier" : "language: nl" }, { "hasPropertyName" : "hasLabel", "hasDataType" : "string", "hasSpecifier" : "language: en" }] }
The text was updated successfully, but these errors were encountered:
I found a very simple solution that gives the same effect as an OrderedDict:
lanprops = [] for lan in languages prop = Mongoc.BSON() prop["hasPropertyName"] = "hasLabel" prop["hasDataType"] = "string" prop["hasSpecifier"] = "language: " * lan push!(lanprops, prop) end initdoc = Mongoc.BSON() initdoc["_id"] = "itemType" initdoc["hasBaseType"] = "systemItem" initdoc["hasProperties"] = lanprops push!(collection, initdoc)
This way the given order of the key-value pair is maintained.
Sorry, something went wrong.
No branches or pull requests
I have the following code:
The OrderedDict gives the following error:
When I change the OrderedDict to a ‘regular’ Dict everything works fine. What can I do to make the OrderedDict working okay in Mongoc.BSON()?
The end result must look like this (the order of the key-value pairs under hasProperties is important):
The text was updated successfully, but these errors were encountered: