Looking for library for serializing F# types to Mongo BSON

Hi, I am looking for a library for (de)serializing F# types such as lists, records, and discriminated unions to and from MongoDB BSON.

The ones I’ve found are not complete or have bugs. I wonder what other people use for this?

I’ve looked at

As I see it, I have the following options:

  • Ideally, wait for someone here to reply with the battle-tested library that they use
  • Manually write serializers for the types I need
  • Fork and fix one of the existing libraries or create a new one
  • Perhaps use one of the FSharp → JSON libraries and then convert the JSON into BSON, if that works.

Looking forward to hearing back from you, thanks in advance :blush:

I ended up making my own with inspiration from the two listed. I’ll make it public when it is more solidified.

1 Like

That’s awesome! Im excited to see how it pans out. I’m using F# and MongoDB as well for a personal project and ran into the same issues. I ended up going the route of least resistance, using classes where I interact with MongoDB and then converting to the F# types that make up my domain.