amilajack / falcon-core-old

The cross-database ORM that powers falcon
MIT License
2 stars 1 forks source link

PR: Implement Parser (getSchema() API) #32

Open amilajack opened 7 years ago

amilajack commented 7 years ago

We need falcon-core to return a graph representation of the database. The implementation should work for SQLite initially. We need to agree on a JSON representation for the graph representation.

sqleton has code for getting the relationships for SQLite

See https://github.com/falcon-client/falcon/issues/22 for the UI implementation.

We'll need this AST parser for the SQL syntax to easily get the constraints and other data. See this website for an example of the AST

Proposed API:

getSchema: (tableName: string) => Promise<Array<{
  columnName: string,
  type: 'int' | 'string', // etc
  default: string,
  constraints: Array<{
    type: 'min' | 'autoIncrements' | 'foreignKey', // etc
    metadata: { [key: string]: any }
  }>
}>>

All sqlite constraints:

A set of SQL constraints for each table. SQLite supports UNIQUE, NOT NULL, CHECK and FOREIGN KEY constraints.

Tasks

getTablePropertiesSql() dropTable()

amilajack commented 7 years ago

@jooohhn what are your thoughts on the API?

jooohhn commented 7 years ago

Wouldn't this method be called with a table to return its schema? i.e. getSchema: (tableName: string)

amilajack commented 7 years ago

Agreed!