Build data stub from database for programer
yarn add data-stub
npx data-stub -f ls
set config at workdir with name: app.json
{
"mysql": {
"host": "127.0.0.1",
"user": "ketchup",
"password": "123456",
"database": "ketchup",
"port": 3306,
"charset": "utf8"
},
"prefix": "tb"
}
data-stub -f ls
list table in the specific database
data-stub -t tableName
show result of the tableName
data-stub -f generate -o outputDir
generate data stub to outputDir
// Code generated by data-stub. DO NOT EDIT.
// source: tableName [fileName]
var BaseModel = require('../model')
var model = {
table: 'tableName',
fields: {
'columnName': {
type: String,
name: 'columnName',
comment: 'comment from db',
}
}
}
module.exports = new BaseModel(model)