fix modelname
This commit is contained in:
parent
81a7bd3811
commit
da85732bbf
|
@ -22,16 +22,18 @@ function wrap(db, dir) {
|
|||
}
|
||||
|
||||
function camelCase(str) {
|
||||
return str.replace(
|
||||
str = str.replace(
|
||||
/_([a-z])/g
|
||||
, function (g) {
|
||||
return g[1].toUpperCase();
|
||||
});
|
||||
return g[1].toUpperCase();
|
||||
}
|
||||
);
|
||||
return str;
|
||||
}
|
||||
|
||||
function upperCamelCase(str) {
|
||||
// TODO handle UTF-8 properly (use codePointAt, don't use slice)
|
||||
return camelCase(str).charAt(0).toUpperCase() + str.slice(1);
|
||||
return str.charAt(0).toUpperCase() + camelCase(str).slice(1);
|
||||
}
|
||||
|
||||
function createTable(opts) {
|
||||
|
@ -379,11 +381,14 @@ function wrap(db, dir) {
|
|||
|
||||
dir.forEach(function (opts) {
|
||||
promises.push(createTable(opts).then(function (dbw) {
|
||||
var tablename = (opts.tablename || 'data');
|
||||
var modelname = opts.modelname;
|
||||
|
||||
tablename = upperCamelCase(tablename);
|
||||
if (!modelname) {
|
||||
modelname = (opts.tablename || 'data');
|
||||
modelname = upperCamelCase(modelname);
|
||||
}
|
||||
|
||||
dbsMap[tablename] = dbw;
|
||||
dbsMap[modelname] = dbw;
|
||||
|
||||
return dbw;
|
||||
}));
|
||||
|
|
Loading…
Reference in New Issue