checkiz / elixir-bson Goto Github PK
View Code? Open in Web Editor NEWBSON documents in Elixir language
Home Page: bsonspec.org
License: MIT License
BSON documents in Elixir language
Home Page: bsonspec.org
License: MIT License
Hi,
I am using elixir-mongodb which relies on this lib, now by default this returns maps with atom keys, I however would like it to return maps with string keys. So I added the following configuration:
config :bson,
decoder_new_doc: &Bson.Decoder.elist_to_map/1
In the console I can check that it is loaded correctly:
iex(3)> Application.get_env(:bson, :decoder_new_doc, &Bson.Decoder.elist_to_atom_map/1)
&Bson.Decoder.elist_to_map/1
But when I execute the following I still get atom keys:
iex(4)> [{"a", 1}, {"b", 2}] |> Bson.encode |> Bson.decode
%{a: 1, b: 2}
From looking at the code I should be doing what I am doing, but obviously I am doing something wrong.
It would be nice if there were a way to generate new ObjectIds.
Please check Documentation.
I tried to compile it changing the elixir version on mix.exs. But I got the error:
== Compilation error on file lib/bson.ex ==
** (CompileError) lib/bson.ex:176: function size/1 undefined
(stdlib) lists.erl:1336: :lists.foreach/2
(stdlib) erl_eval.erl:657: :erl_eval.do_apply/6
(elixir) src/elixir.erl:170: :elixir.erl_eval/3
(elixir) src/elixir.erl:158: :elixir.eval_forms/4
(elixir) src/elixir_lexical.erl:17: :elixir_lexical.run/2
(elixir) src/elixir.erl:170: :elixir.erl_eval/3
When attempting to decode an empty array, the code triggers the following error:
iex(1)> Bson.Encoder.document(%{a: []}) |> Bson.Decoder.document
[what: ["a", {:kind, 0}], acc: [[], []], rest: {-2, ""}]
When attempting to decode an empty string, the decoder triggers the following error:
[what: ["a", :bytestring], acc: [[]], rest: {1, <<0, 0>>}]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.