Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage with Godot Mono (C#) #3

Open
3ddelano opened this issue Oct 11, 2023 · 0 comments
Open

Usage with Godot Mono (C#) #3

3ddelano opened this issue Oct 11, 2023 · 0 comments

Comments

@3ddelano
Copy link
Owner

Although this plugin doesn't natively support C# we can still use this plugin in Godot projects if you really want to.
The best approach would be to use the Official C# mongodb package

using Godot;
using System;

public class Main : Control
{
    public override void _Ready()
    {
        GDScript MongoDriver = (GDScript) GD.Load("res://addons/mongo-driver-godot/wrapper/mongo_driver.gd");
        // Need to manually type-cast to Godot.Object each time
        Godot.Object driver = (Godot.Object) MongoDriver.New();
        Godot.Object conn = (Godot.Object) driver.Call("connect_to_server", "mongodb://localhost:27017");
        Godot.Object db = (Godot.Object) conn.Call("get_database", "test");
        Godot.Object col = (Godot.Object) db.Call("get_collection", "products");
        GD.Print(col.Call("find"));
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant