|
1 | 1 | # FSharp.MongoDB
|
2 | 2 |
|
3 |
| -> an F# interface for the MongoDB .NET driver |
| 3 | +> an F# interface for the MongoDB .NET [C# driver][csharp_driver]. |
4 | 4 |
|
5 | 5 | ## Goals of this project
|
6 | 6 |
|
7 | 7 | * Provide an idiomatic F# API for interacting with MongoDB.
|
8 | 8 | * Have an implementation that is fully testable without connecting to a server.
|
9 |
| - |
| 9 | + * Isomorphic bson serialization for C# and F#. |
| 10 | + |
10 | 11 | ## FSharp.MongoDB history
|
11 | 12 |
|
12 | 13 | Repository origins are:
|
@@ -43,6 +44,46 @@ On startup you have to register serializers:
|
43 | 44 | MongoDB.Bson.Serialization.FSharp.register()
|
44 | 45 | ```
|
45 | 46 |
|
| 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 | + |
46 | 87 | # License
|
47 | 88 | The contents of this library are made available under the [Apache License, Version 2.0][license].
|
48 | 89 |
|
|
0 commit comments