Advertisement
FazeFew

Untitled

Jan 18th, 2020
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. using MongoDB.Driver;
  2. using UnityEngine;
  3.  
  4. public class Mongo
  5. {
  6. private const string MONGO_URI = "mongodb+srv://ola:Odumade@xeonsectorfs-q3tdw.mongodb.net/test";
  7. private const string DATABASE_NAME = "lobbydb";
  8.  
  9. private MongoClient client;
  10. private MongoServer server;
  11. private MongoDatabase db;
  12.  
  13. private MongoCollection accounts;
  14.  
  15. public void Init()
  16. {
  17. client = new MongoClient(MONGO_URI);
  18. server = client.GetServer();
  19. db = server.GetDatabase(DATABASE_NAME);
  20.  
  21. // This is where we would initialize collections
  22. accounts = db.GetCollection<Model_Account>("account");
  23.  
  24. Debug.Log("Database has been initialized");
  25. }
  26. public void Shutdown()
  27. {
  28. client = null;
  29. server.Shutdown();
  30. db = null;
  31. }
  32.  
  33. #region Insert
  34. public bool InsertAccount(string username, string password, string email)
  35. {
  36. Model_Account newAccount = new Model_Account();
  37. newAccount.Username = username;
  38. newAccount.ShaPassword = password;
  39. newAccount.Email = email;
  40. newAccount.Discriminator = "0000";
  41.  
  42. accounts.Insert(newAccount);
  43.  
  44. return true;
  45. }
  46.  
  47. #endregion
  48.  
  49. #region Find
  50. #endregion
  51.  
  52. #region Update
  53. #endregion
  54.  
  55. #region Delete
  56. #endregion
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement