Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Settings
- let init() =
- //anonymous function with parameter s
- ArangoDatabase.ChangeSetting(fun s ->
- //arrow is for setting the data
- s.Url <- "http://ip:port"
- s.Database <- "MainDatabase"
- s.Credential <- new NetworkCredential("username", "password")
- s.SystemDatabaseCredential <- new NetworkCredential("username", "password")
- s.CreateCollectionOnTheFly <- false
- s.WaitForSync <- true
- )
- //Creates database instance and returns it
- let MainDb() = ArangoDatabase.CreateWithSetting()
- ///////////////////////////////////////
- //function for inserting player into database
- let createPlayer ID email salt hash clanID =
- let newPlayer = new Player(ID, email, salt, hash, clanID)
- use db = MainDb() //use means using in C#
- db.InsertAsync<Player>(newPlayer, baseResult = resHandler("createPlayer"))
- |> awaitCatch
- ////////////////////////////////////////
- //function which returns player from database by its ID
- let getPlayer ID =
- use db = MainDb() //use means using in C#
- db.DocumentAsync<Player>(ID, baseResult = resHandler("getPlayer"))
- |> awaitCatch
- ////////////////////////////////////
- //awaits task with possible exception
- let awaitCatch task =
- task
- |> Async.AwaitTask
- |> Async.Catch
- //////////////////////////////////
- //class in C#, what you see here are parameters with types for constructing new object
- type public Player(ID:string, email:string, salt:byte[], hash:byte[], clanID:string) =
- [<DocumentProperty(Identifier = IdentifierType.Key)>]
- member public this.ID = ID
- member public this.email = email
- member public this.salt = salt
- member public this.hash = hash
- member public this.clanID = clanID
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement