F# and RavenDB

Unrelated home shot

Getting Started with RavenDB

First things first, we need a local environment

docker run --rm -d -p 9010:8080 -p 38888:38888 --name ravendb -e RAVEN_Setup_Mode=None -e RAVEN_License_Eula_Accepted=true -e RAVEN_Security_UnsecuredAccessAllowed=PrivateNetwork ravendb/ravendb

Connecting to RavenDB

There is a C# example, what I came up with is:

.AddSingleton<IRavenClientFactory, RavenClientFactory>(fun sp ->
let configurationSection = config.GetSection("Raven")
let url = configurationSection.GetValue("Url")
let dbName = configurationSection.GetValue("Database")
new RavenClientFactory([ url ], dbName)
)

Reading from RavenDB

I created just a simple wrapper over the reading and writing. Nothing more than to just handle the extra orthogonal concerns that are coming later.

Interesting Time

So, lets dive into some more interesting aspects.

  1. I want auto database creation
  2. Seamless integration with Domain Objects and Value Objects

Auto Database Creation

Why? During my local development, I switch between computers, sometimes I use my “big” computer — a.k.a. Tower PC — sometimes I like to sit and watch TV whilst coding — as I’m doing now whilst writing this blog. Each time, I want my database and other resources of my APIs/websites to be able to auto generate their seed data etc…

Seamless Integration with DDD

Well, you’ll have to wait till next time… :D

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store