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

Ideal API #27

Open
amilajack opened this issue Mar 11, 2018 · 0 comments
Open

Ideal API #27

amilajack opened this issue Mar 11, 2018 · 0 comments

Comments

@amilajack
Copy link
Member

amilajack commented Mar 11, 2018

The API from sqlectron was pretty unorganized. Because falcon-core was a fork of it, we had to borrow its architecture. I think core has matured enough to the point where we can migrate away from sqlectron's API and move towards one of our own: one that's more object oriented and namespaced to allow for faster imports, which we need. To keep a lot of the lower level database specific logic out of the UI, this newer API for falcon-core should be higher level.

import { ConnectionPool, ConnectionManager } from 'falcon-core';
import { SqliteProvider } from 'falcon-core/sqlite';

const connetionManager = new ConnetionManager();
const pool = new ConnectionPool();
const provider = new SqliteProvider();

const dbConn = await provider.connect({
  database: 'demo.sqlite',
  readonly: true
});
connectionManager.add(dbConn.config);
pool.add(dbConn);

// Connect to a favorite connection
const [firstConnection] = await connectionManager.getAll();
firstConnection.connect();
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