Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

NoSQL Helper Libraries: FSharpCouch and MongoFS

DZone's Guide to

NoSQL Helper Libraries: FSharpCouch and MongoFS

· Database Zone
Free Resource

Learn NoSQL for free with hands-on sample code, example queries, tutorials, and more.  Brought to you in partnership with Couchbase.

I've been working on a few new libraries lately that focus on providing functional wrappers around various NoSQL options.

FSharpCouch:

FSharpCouch is something that I wrote about a little over two years ago. At the time, it was more of an educational exercise, but I have since revised it and found aspects of it to be useful. This is now available on NuGet as package ID FSharpCouch.

Here's an example:

type Person = {
    FirstName : string
    LastName : string
}

let couchUrl = "http://localhost:5984"
let databaseName = "people"

let result = { FirstName = "John"; LastName = "Doe" }
             |> createDocument couchUrl databaseName

let createdPerson = getDocument<Person> couchUrl databaseName result.id


You can find additional examples and the full source at https://github.com/dmohl/FSharpCouch.

MongoFs:

MongoFs currently has a primary focus on function composition as it relates to setting up the MongoDB client aspects of server, database, and collection. It simply wraps functions around the necessary methods of the C# Mongo Driver and auto opens the encompassing module.

Here's an example:

let dbName = "SomeName"
let collectionName = "SomeName"

type Person = {
    mutable _id : ObjectId
    mutable FirstName : string
    mutable LastName : string
}

createLocalMongoServer()
|> getMongoDatabase dbName
|> getMongoCollection<Person> collectionName

{ _id = ObjectId.GenerateNewId(); FirstName = "John"; LastName = "Doe" }
|> people.Insert |> ignore

let person = people.FindOne()


You can get it from NuGet as package ID MongoFs and find more examples and source at https://github.com/dmohl/MongoFs.
 

The Getting Started with NoSQL Guide will get you hands-on with NoSQL in minutes with no coding needed. Brought to you in partnership with Couchbase.

Topics:

Published at DZone with permission of Daniel Mohl, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}