falcon-client / falcon-core Goto Github PK
View Code? Open in Web Editor NEWThe cross-database ORM that powers falcon
License: MIT License
The cross-database ORM that powers falcon
License: MIT License
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();
Complements falcon-client/falcon#45
https://www.sqlite.org/lang_altertable.html
The sqlite docs actually discuss how to manipulate the schema. We should investigate this.
UPDATE: db browser uses this file to create and transform sqlite ast's
UPDATE: Make sure to take advantage of sqlite savepoints. Create a savepoint before making schema changes
Add rollup to bundle all the code and the deps. This is much better than publishing the packages themselves
Would be useful in the falcon front to offload some of the logic. Right now it's convoluted
Investigate:
The basic idea with this is that each provider can return a list of features it supports. ex:
connection.hasFeatures('views') // false
Reference: https://www.sqlite.org/withoutrowid.html
rowid
- these may or may not have a primary keyrowid
- these must have a primary keyTODO:
update()
and delete()
to handle tables with rowid
and without rowid
Support for erroring if db version is lower than minimum supported version.
onTableChange
: Define a callback to fire when a table is changedonDatabaseChange
: Define a callback to fire when a database is changedtype cbType = (dbName: string, tableName: string) => Promise<void>;
type onTableChange = (cb: cbType) => Promise<void>;
type onDatabaseChange = (cb: cbType) => Promise<void>;
Use cases:
node-sqlite
recently fixed this. Need to bump deps to fix this
The current API requires the database to be given as a configuration argument to falcon. Sometimes the user might not know the database of a given connection. This works for sqlite but it wont work for other database types, such as mysql which can have multiple databases.
Change all the methods in ProviderInterface
to accept a database
argument before the table
Many databases show details of users, each of which have certain privileges. We need to be able to expose users and their privileges through an API.
We can ignore this for sqlite but we'll eventually need to implement this for other databases
To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.
Since we didn’t receive a CI status on the greenkeeper/initial
branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.
If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/
.
Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial
branch in this repository, and then remove and re-add this repository to the Greenkeeper App’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.
I forgot that es6 built-ins are extendable. Instead of returning an array of error messages, we can use try/catch by creating a class like this:
class FalconError extends Error {
constructor(message, data) {
super(message)
this.data = data
}
}
try {
throw new FalconError('falcon err here', { foo: 'asdf' })
console.log('asdf')
} catch(e) {
console.log(e.data)
}
The current api requires all the service providers to be loaded when falcon-core
is imported. falcon-core
currently takes about an entire second to load. Each provider requires its own native dependency. For example, the SqliteProvider
depends on sqlite3
, which is a native dep. Webpack can't work with native deps yet so this really hurts our perf of importing native deps (which includes falcon-core
). We should migrate to an api which allows users of falcon-core
to import only the providers they need like so:
async function main() {
const { SqliteProvider } = import('falcon-core')
const serverInfo = {...};
const serverSession = db.createServer(SqliteProvider, serverInfo);
const connection = await serverSession.createConnection('demo.sqlite');
await connection.connect();
const schema = await connection.getSchema('tracks');
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.