Revisions

gist: 218388 Download_button fork
public
Public Clone URL: git://gist.github.com/218388.git
Embed All Files: show embed
MongoDB and F# #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#if INTERACTIVE
#I @"C:\Tools\MongoDB-CSharp\MongoDB.Linq\bin\Debug"
#r "MongoDB.Driver.dll"
#r "MongoDB.Linq.dll"
#r "FSharp.PowerPack.Linq.dll"
#r "System.Core.dll"
#endif
 
open System
open MongoDB.Driver
open MongoDB.Linq
open Microsoft.FSharp.Linq.Query
open System.Linq
 
let mongo = new Mongo()
let connected = mongo.Connect()
 
let db = mongo.["movieDB"]
db.["movies"].Insert((new Document()).Append("title", "Star Wars").Append("releaseDate", DateTime.Now))
 
let movies = db.["movies"].AsQueryable() :> IQueryable<Document>
 
let titles =
  query <@ seq { for movie in movies do
                   yield movie } @>
                   
let disconnected = mongo.Disconnect()