After a few philosophical blog posts, I decided it was time for something a bit more concrete. I’ve been playing around a bit with F# and some web stuff recently using both RavenDB and PicoMvc so I thought I’d share with you how to create an autocomplete drop down using these technologies.
Creating an autocomplete in a HTML form is fairly common these days and there’s a nice jQuery plugin that takes care of the UI side of things. So the heavy lifting that remains, although it’s not really that heavy, is loading the data into RavenDB then exposing a service that will return JSON records corresponding to the users searching.
In this scenario I’m going to create a drop down based on the French “Communes” an administrative area in France that’s roughly equivalent to the idea of a town. This is just because I have the data to hand.
The way we’re going to structure our project is:
Common contains the definition of our types that will be stored in RavenDB and will be referenced from LoadCommunes and Web, which will contain the ETL logic and the logic to drive the web pages respectively. The project WebHost is a C# “web project” it’s just there to hold the html parts of the project and make launching the web server for debugging easier.
So that the scenario and the project setup done, next time we’ll see some actual code when we look at the ETL. If you can’t wait that long the full code base is already available on github in the new examples directory of picomvc.
A quick caveated is that since writing this series I’ve read Ayende’s Modeling Reference Data in RavenDB, the approach we take here is a little different to the one he suggests, I’ll discuss alterative implementations at the end of the series.