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

[Feature Request] Exposing a singular database object. #1

Open
OoLunar opened this issue Oct 31, 2021 · 0 comments
Open

[Feature Request] Exposing a singular database object. #1

OoLunar opened this issue Oct 31, 2021 · 0 comments
Labels
Documentation Improvements or additions to documentation Enhancement New feature or request Help Wanted Extra attention is needed

Comments

@OoLunar
Copy link
Member

OoLunar commented Oct 31, 2021

What's your suggestion?

On the server class, a database object should be exposed to everything, plugin API included. The database object should be able to dynamically create tables based off of an object.

Why do you feel this should be added?

Having a single database available will prevent having 20 sqlite files laying around. It could also be used to prevent plugins from having filesystem access.

Do you have a rough idea of how this should be implemented? If so, how?

The table name should be prefixed with the plugin's name, along with whatever table name the plugin provides. A proof of concept:

public class EssentialsPlugin : Plugin {
    public async Task Main(IConfiguration serverConfig, Database serverDatabase) {
        ITable<Warp> warps = serverDatabase.CreateTable<Warp>("warps"); // Creates table essentials_warps
        Warp spawnWarp = warps.FirstOrDefault(databaseWarp => databaseWarp.Name == "spawn");
        spawnWarp.Coordinates = new Vector(0, 64, 0);
        warps.SaveChanges();
    }
}

I expect the final example to look very different, however the concept is here.

What gave you this idea? Was it related to a certain problem or inconvenience?

Multiple inconveniences when managing plugins.

Have any alternatives been considered?

N/A

Personal notes

N/A

@OoLunar OoLunar added Documentation Improvements or additions to documentation Enhancement New feature or request Help Wanted Extra attention is needed labels Oct 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Improvements or additions to documentation Enhancement New feature or request Help Wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant