Database schema defenition extension for matter in motion framework
Extensions installation instructions
- Add this extension
- Add schema extension for your database
Define a schema in your resource controller with options:
- db — database name. If you use mm-db extension you can omit this. Default database will be used.
- table — table name or an object with table name and table creation options.
- indexes — array of index names or an object with index names and index creation options.
- apply — function. If you define
apply
function it will be called.table
andindexes
options will be ignored. However, you still should still define them to use in your code.
You can define as many tables as you want.
Controller.prototype.schema = {
name: {
table: 'table_name',
indexes: ['index_name1', 'index_name2']
}
}
Controller.prototype.schema = {
name: {
db: 'database driver name',
table: {
'table_name': tableOptions
},
indexes: {
'index_name1': indexOptions1,
'index_name2': indexOptions2,
}
}
}
Controller.prototype.schema = {
name: {
db: 'database driver name',
//this will be used as description only
table: 'table_name',
indexes: ['index_name1', 'index_name2'],
//here is actual schema
apply: function(dbDriver, schema) {
//do any stuff nessesary and return a promise
}
}
}
License: MIT.