I have been developing a mobile game in unity for a while now and it is very DB dependent, so I thought that MongoDB was the best alternative and decided to start studying how it works.
My first solution was downloading the
Unity-mongo-csharp-driver-dlls, given that it seemed pretty simple to use. I tested several things within the editor and made it work EXACTLY as I wanted by fetching the data using the methods below.
client = new MongoClient(MONGO_URI); db = client.GetDatabase(DATABASE_NAME); collection = db.GetCollection<MongoClass>(COLLECTION_NAME);
and then I was able to do whatever I wanted with the data, like fetch all:
List<MongoClass> fetchedList = collection.Find(i => true).ToList();
But, once I had the project built to mobile, It stopped working, as explained in this topic by people with similar issues: MongoDB and Unity il2cpp Mobile Builds.
So I started studying the MongoDB Realm as an alternative and found it very confusing. I believe it is due to the fact that it is still in alpha, but even so, I followed the steps and imported the package from GitHub as orientated, but couldn’t get much farther than that.
What I wish to do is the same as I described above BUT something that still works on mobile builds.
I also came across this topic but couldn’t apply the recommendation: Accessing Realm features with Unity and C#.
For starters I was not able to specify a MongoClient for some reason. This is the error that I get:
Realms.Sync.MongoClient 'MongoClient' does not contain a constructor that takes 1 arguments
Anyway, I described thoroughly what I aim to achieve and the problems to do so. I will be waiting for a reply!