Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using MongoDB.Driver;
- using UnityEngine;
- public class Mongo
- {
- private const string MONGO_URI = "mongodb+srv://ola:Odumade@xeonsectorfs-q3tdw.mongodb.net/test";
- private const string DATABASE_NAME = "lobbydb";
- private MongoClient client;
- private MongoServer server;
- private MongoDatabase db;
- private MongoCollection accounts;
- public void Init()
- {
- client = new MongoClient(MONGO_URI);
- server = client.GetServer();
- db = server.GetDatabase(DATABASE_NAME);
- // This is where we would initialize collections
- accounts = db.GetCollection<Model_Account>("account");
- Debug.Log("Database has been initialized");
- }
- public void Shutdown()
- {
- client = null;
- server.Shutdown();
- db = null;
- }
- #region Insert
- public bool InsertAccount(string username, string password, string email)
- {
- Model_Account newAccount = new Model_Account();
- newAccount.Username = username;
- newAccount.ShaPassword = password;
- newAccount.Email = email;
- newAccount.Discriminator = "0000";
- accounts.Insert(newAccount);
- return true;
- }
- #endregion
- #region Find
- #endregion
- #region Update
- #endregion
- #region Delete
- #endregion
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement