Skip to content

Instantly share code, notes, and snippets.

@brianberns
Created April 6, 2021 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianberns/1f8799f661c70b5013fd11ce9ac9bee5 to your computer and use it in GitHub Desktop.
Save brianberns/1f8799f661c70b5013fd11ce9ac9bee5 to your computer and use it in GitHub Desktop.
open MongoDB.Bson
open MongoDB.Driver
type User =
{
_id : BsonObjectId
Name : string
}
[<EntryPoint>]
let main argv =
let client = MongoClient("mongodb://localhost:27017")
let db = client.GetDatabase("test")
let coll = db.GetCollection<User>("User")
let filter =
Builders<User>
.Filter
.Regex(
(fun user -> user.Name :> obj),
BsonRegularExpression("o"))
for entry in coll.Find(filter).ToEnumerable() do
printfn "%A" entry
0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment