MongoDB-Unity is a Unity package that simplifies the use of the MongoDB.Driver within Unity projects. It allows developers to seamlessly integrate MongoDB for data storage, enabling robust game features and persistence.
- Connect to MongoDB databases directly from Unity.
- Perform CRUD operations easily.
- Supports asynchronous operations for improved performance.
- Lightweight and easy to set up.
dotnet new classlib --framework "netstandard2.0" -o MongoDBUnity
cd MongoDBUnity
dotnet add package MongoDB.Driver
dotnet publish
- Download the latest release of the package from the latest release and import it to your project.
- Import the
.unitypackage
file into your Unity project.
MongoDB-Unity can also be installed via UPM package.
https://github.com/trongtindev/MongoDB-Unity.git?path=/Assets/MongoDB-Unity
using MongoDB.Bson;
using MongoDB.Driver;
var client = new MongoClient("mongodb://localhost:27017");
var database = client.GetDatabase("foo");
var collection = database.GetCollection<BsonDocument>("bar");
await collection.InsertOneAsync(new BsonDocument("Name", "Jack"));
var list = await collection.Find(new BsonDocument("Name", "Jack"))
.ToListAsync();
foreach(var document in list)
{
Console.WriteLine(document["Name"]);
}
Currently, MongoDB-Unity supports Windows, macOS and Linux.
Contributions are welcome! Please open issues or submit pull requests for any improvements or bug fixes.