We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e989801 commit dc663b2Copy full SHA for dc663b2
lib/bson/types.ex
@@ -138,6 +138,10 @@ defmodule BSON.ObjectId do
138
"#BSON.ObjectId<#{encoded}>"
139
end
140
141
+
142
+ defimpl String.Chars do
143
+ def to_string(id), do: BSON.ObjectId.encode!(id)
144
+ end
145
146
147
defmodule BSON.Regex do
test/bson/types_test.exs
@@ -42,6 +42,10 @@ defmodule BSON.TypesTest do
42
assert BSON.ObjectId.decode("") == :error
43
44
45
+ test "to_string BSON.ObjectId" do
46
+ assert to_string(@objectid) == @string
47
48
49
test "inspect BSON.Regex" do
50
value = %BSON.Regex{pattern: "abc"}
51
assert inspect(value) == "#BSON.Regex<\"abc\", \"\">"
0 commit comments