Skip to content

Commit 8ee6941

Browse files
authored
Enhance documentation (#20)
Update goals and serialization formats.
1 parent 5a3ab97 commit 8ee6941

File tree

1 file changed

+43
-2
lines changed

1 file changed

+43
-2
lines changed

README.md

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# FSharp.MongoDB
22

3-
> an F# interface for the MongoDB .NET driver
3+
> an F# interface for the MongoDB .NET [C# driver][csharp_driver].
44
55
## Goals of this project
66

77
* Provide an idiomatic F# API for interacting with MongoDB.
88
* Have an implementation that is fully testable without connecting to a server.
9-
9+
* Isomorphic bson serialization for C# and F#.
10+
1011
## FSharp.MongoDB history
1112

1213
Repository origins are:
@@ -43,6 +44,46 @@ On startup you have to register serializers:
4344
MongoDB.Bson.Serialization.FSharp.register()
4445
```
4546

47+
# Serialization format
48+
49+
## List
50+
`List<_>` is serialized as an array. Order is preserved.
51+
52+
## Set
53+
`Set<_>` is serialized as an array. Do not rely on the order.
54+
55+
## Array
56+
`List<_>` is serialized as an array. Order is preserved.
57+
58+
## Seq
59+
`Seq<_>` is serialized as an array. Order is preserved.
60+
61+
## Map
62+
`Map<_, _>` is serialized as an object. Do not rely on the order of the keys.
63+
64+
## Option
65+
`Option<_>` is either serialized as:
66+
* `null` if `Option.None`
67+
* `object` if `Option.Some`
68+
69+
On deserialization, missing value is mapped to `None`.
70+
71+
## ValueOption
72+
`ValueOption<_>` is either serialized as:
73+
* `null` if `ValueOption.ValueNone`
74+
* `object` if `ValueOption.ValueSome`
75+
76+
On deserialization, missing value is mapped to `ValueNone`.
77+
78+
## Record
79+
A record is serialized as an `object.
80+
81+
If you want to auto-generate `ObjectId` (as the Id of the collection), add `[<CLIMutable>]` on the record.
82+
83+
## Discriminated union
84+
The case of the discriminated union is stored in `_t` key.
85+
Each value of the DU is serialized as an `object` using its corresponding value name.
86+
4687
# License
4788
The contents of this library are made available under the [Apache License, Version 2.0][license].
4889

0 commit comments

Comments
 (0)