preserve stuff before trying something craz
This commit is contained in:
@ -4,11 +4,11 @@ let def: SystemDef = {
|
||||
storage: {
|
||||
tables: [
|
||||
{
|
||||
name: "tasks",
|
||||
name: "task",
|
||||
relations: [
|
||||
{
|
||||
type: 'belongs-to',
|
||||
table: 'lists',
|
||||
table: 'list',
|
||||
}
|
||||
],
|
||||
columns: [
|
||||
@ -40,7 +40,7 @@ let def: SystemDef = {
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "lists",
|
||||
name: "list",
|
||||
relations: [],
|
||||
columns: [
|
||||
{
|
||||
@ -52,7 +52,7 @@ let def: SystemDef = {
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "users",
|
||||
name: "user",
|
||||
relations: [],
|
||||
columns: [
|
||||
{
|
||||
@ -70,9 +70,9 @@ let def: SystemDef = {
|
||||
],
|
||||
relations: [
|
||||
{
|
||||
left: 'lists',
|
||||
left: 'list',
|
||||
relation: 'many-to-many',
|
||||
right: 'users',
|
||||
right: 'user',
|
||||
columns: [
|
||||
{
|
||||
name: 'access',
|
||||
@ -83,7 +83,60 @@ let def: SystemDef = {
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
views: [
|
||||
{
|
||||
component: 'task',
|
||||
type: ['list', 'count'],
|
||||
columns: [
|
||||
'name',
|
||||
'description',
|
||||
'completed',
|
||||
'completed_date',
|
||||
],
|
||||
orderBy: [
|
||||
{
|
||||
column: 'modified',
|
||||
direction: 'desc'
|
||||
}
|
||||
],
|
||||
filters: [
|
||||
{
|
||||
param: 'list',
|
||||
column: 'list_id',
|
||||
comparison: '=',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
param: 'completed',
|
||||
column: 'completed',
|
||||
comparison: '=',
|
||||
required: false
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
component: 'list',
|
||||
type: ['list', 'count'],
|
||||
columns: [
|
||||
'name',
|
||||
],
|
||||
orderBy: [
|
||||
{
|
||||
column: 'modified',
|
||||
direction: 'desc'
|
||||
}
|
||||
],
|
||||
filters: [
|
||||
{
|
||||
param: 'user',
|
||||
column: 'user_id',
|
||||
comparison: '=',
|
||||
required: true
|
||||
},
|
||||
]
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
export default def;
|
||||
|
@ -1,5 +1,9 @@
|
||||
import * as path from 'path';
|
||||
import simmer from './simmer-def-example';
|
||||
const ncp = require('ncp').ncp;
|
||||
// import defs from './example-def';
|
||||
|
||||
import defs from './example-def';
|
||||
declare var __dirname: any;
|
||||
|
||||
function createDatabase(storageDef: StorageDef) {
|
||||
let tableCreationQueries: string[] = [];
|
||||
@ -66,7 +70,15 @@ function getTableRelationsCreationString(relationsDef: ManyToManyDef): string {
|
||||
}
|
||||
|
||||
|
||||
createDatabase(defs.storage);
|
||||
ncp(path.join(__dirname, 'frame'), path.join(__dirname, 'test'), (err: any) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
} else {
|
||||
console.log('success copying files');
|
||||
}
|
||||
});
|
||||
|
||||
createDatabase(simmer.storage);
|
||||
|
||||
|
||||
|
||||
@ -74,6 +86,7 @@ createDatabase(defs.storage);
|
||||
|
||||
interface SystemDef {
|
||||
storage: StorageDef;
|
||||
views: ViewDef[];
|
||||
// TODO: add Views, ACLs, Behaviors, UX
|
||||
}
|
||||
|
||||
@ -82,6 +95,28 @@ interface StorageDef {
|
||||
relations: ManyToManyDef[];
|
||||
}
|
||||
|
||||
interface ViewDef {
|
||||
component: string;
|
||||
type: ('list' | 'count' | 'item' | 'distinct')[];
|
||||
columns: string[];
|
||||
orderBy?: Order[];
|
||||
filters?: Filter[];
|
||||
// if type is 'list' it will always include skip and limit for pagination
|
||||
}
|
||||
|
||||
interface Order {
|
||||
column: string;
|
||||
direction: 'asc' | 'desc';
|
||||
}
|
||||
|
||||
interface Filter {
|
||||
param: string; // the query param used to get the value
|
||||
column: string;
|
||||
comparison: '=' | '!=' | '>' | '<' | 'contains';
|
||||
value?: string;
|
||||
required?: boolean;
|
||||
}
|
||||
|
||||
interface TableDef {
|
||||
name: string;
|
||||
columns: ColumnDef[],
|
||||
|
95
src/simmer-def-example.ts
Normal file
95
src/simmer-def-example.ts
Normal file
@ -0,0 +1,95 @@
|
||||
import { SystemDef } from './processDef';
|
||||
|
||||
var simmer: SystemDef = {
|
||||
storage: {
|
||||
tables: [
|
||||
{
|
||||
name: 'cooks',
|
||||
relations: [],
|
||||
columns: [
|
||||
{
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
nullable: false
|
||||
},
|
||||
{
|
||||
name: 'location',
|
||||
type: 'string',
|
||||
nullable: false
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'customers',
|
||||
relations: [],
|
||||
columns: [
|
||||
{
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
nullable: false
|
||||
},
|
||||
{
|
||||
name: 'location',
|
||||
type: 'string',
|
||||
nullable: false
|
||||
},
|
||||
{
|
||||
name: 'cardInfo',
|
||||
type: 'string',
|
||||
nullable: true
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'dishes',
|
||||
relations: [
|
||||
{
|
||||
type: 'belongs-to',
|
||||
table: 'cooks',
|
||||
}
|
||||
],
|
||||
columns: [
|
||||
{
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
nullable: false
|
||||
},
|
||||
{
|
||||
name: 'picture',
|
||||
type: 'string',
|
||||
nullable: false
|
||||
},
|
||||
{
|
||||
name: 'prices',
|
||||
type: 'string',
|
||||
nullable: true
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'ratings',
|
||||
relations: [
|
||||
{
|
||||
type: 'belongs-to',
|
||||
table: 'customers',
|
||||
},
|
||||
{
|
||||
type: 'belongs-to',
|
||||
table: 'cooks',
|
||||
}
|
||||
],
|
||||
columns: [
|
||||
{
|
||||
name: 'amount',
|
||||
type: 'number',
|
||||
nullable: false
|
||||
},
|
||||
]
|
||||
},
|
||||
],
|
||||
relations: []
|
||||
},
|
||||
views: []
|
||||
};
|
||||
|
||||
export default simmer;
|
Reference in New Issue
Block a user