Comparing version 0.4.1 to 0.4.2
@@ -31,3 +31,3 @@ 'use strict'; | ||
*/ | ||
exports.count = function () { | ||
exports.count = (() => { | ||
var ref = _asyncToGenerator(function* (ctx) { | ||
@@ -57,3 +57,3 @@ let Model = ctx.Model; | ||
}; | ||
}(); | ||
})(); | ||
@@ -63,3 +63,3 @@ /** | ||
*/ | ||
exports.list = function () { | ||
exports.list = (() => { | ||
var ref = _asyncToGenerator(function* (ctx) { | ||
@@ -87,5 +87,8 @@ let Model = ctx.Model; | ||
}); | ||
if (Model.population) { | ||
Model.population.forEach(p => { | ||
query.populate(p); | ||
if (Model.populations) { | ||
Model.populations.forEach(function (p) { | ||
if (!p.nolist) { | ||
//判断population选项是否不允许列表接口自动populate | ||
query.populate(p); | ||
} | ||
}); | ||
@@ -100,11 +103,13 @@ } | ||
return function list(_x2) { | ||
function list(_x2) { | ||
return ref.apply(this, arguments); | ||
}; | ||
}(); | ||
} | ||
return list; | ||
})(); | ||
/** | ||
* 获取单个对象详细信息 | ||
*/ | ||
exports.show = function () { | ||
exports.show = (() => { | ||
var ref = _asyncToGenerator(function* (ctx) { | ||
@@ -119,4 +124,4 @@ let Model = ctx.Model; | ||
let query = Model.findById(ctx.params.id); | ||
if (Model.population) { | ||
Model.population.forEach(p => { | ||
if (Model.populations) { | ||
Model.populations.forEach(function (p) { | ||
query.populate(p); | ||
@@ -137,11 +142,13 @@ }); | ||
return function show(_x3) { | ||
function show(_x3) { | ||
return ref.apply(this, arguments); | ||
}; | ||
}(); | ||
} | ||
return show; | ||
})(); | ||
/** | ||
* 创建一个对象 | ||
*/ | ||
exports.create = function () { | ||
exports.create = (() => { | ||
var ref = _asyncToGenerator(function* (ctx) { | ||
@@ -170,3 +177,3 @@ let Model = ctx.Model; | ||
}; | ||
}(); | ||
})(); | ||
@@ -176,3 +183,3 @@ /** | ||
*/ | ||
exports.update = function () { | ||
exports.update = (() => { | ||
var ref = _asyncToGenerator(function* (ctx) { | ||
@@ -204,3 +211,3 @@ let Model = ctx.Model; | ||
}; | ||
}(); | ||
})(); | ||
@@ -210,3 +217,3 @@ /** | ||
*/ | ||
exports.remove = function () { | ||
exports.remove = (() => { | ||
var ref = _asyncToGenerator(function* (ctx) { | ||
@@ -238,2 +245,2 @@ let Model = ctx.Model; | ||
}; | ||
}(); | ||
})(); |
@@ -65,3 +65,3 @@ 'use strict'; | ||
disabled: field.disabled, | ||
note: field.note, | ||
help: field.help, | ||
depends: field.depends, | ||
@@ -68,0 +68,0 @@ required: field.required, |
@@ -71,4 +71,6 @@ 'use strict'; | ||
* @class Model | ||
* @extends mongoose.Model | ||
*/ | ||
class Model { | ||
constructor() { | ||
@@ -78,5 +80,2 @@ throw new Error('Can not initialize a Model before register.'); | ||
//placeholder | ||
/** | ||
@@ -87,2 +86,4 @@ * 注册前置钩子 | ||
*/ | ||
//placeholder | ||
static pre(action, fn) { | ||
@@ -356,3 +357,5 @@ this._pre || (this._pre = {}); | ||
schema.methods.data = function () { | ||
let doc = {}; | ||
let doc = { | ||
id: this.id | ||
}; | ||
for (let key in this.schema.tree) { | ||
@@ -373,3 +376,2 @@ if (key[0] == '_' || !model.fields[key] || model.fields[key].private) { | ||
} | ||
doc.id = this.id; | ||
doc.__proto__ = Data; | ||
@@ -376,0 +378,0 @@ return doc; |
@@ -14,3 +14,3 @@ 'use strict'; | ||
module.exports = function () { | ||
module.exports = (() => { | ||
var ref = _asyncToGenerator(function* () { | ||
@@ -63,5 +63,3 @@ this.debug('%s init', this.id); | ||
let configDir = this.dir + '/config/' + serviceId; | ||
if (util.isDirectory(configDir)) { | ||
sub._configDirs.push(configDir); | ||
} | ||
sub._configDirs.push(configDir); | ||
yield sub.init(); | ||
@@ -71,5 +69,7 @@ } | ||
return function init() { | ||
function init() { | ||
return ref.apply(this, arguments); | ||
}; | ||
}(); | ||
} | ||
return init; | ||
})(); |
@@ -100,3 +100,3 @@ 'use strict'; | ||
router.register('/api/:controller?/:action?', ['POST'], function () { | ||
router.register('/api/:controller?/:action?', ['POST'], (() => { | ||
var ref = _asyncToGenerator(function* (ctx, next) { | ||
@@ -130,3 +130,3 @@ let controller = ctx.params.controller; | ||
}; | ||
}()); | ||
})()); | ||
@@ -133,0 +133,0 @@ router.get('/api/:model/count', restApi('count')); |
@@ -30,3 +30,3 @@ 'use strict'; | ||
*/ | ||
ctx.sendfile = function () { | ||
ctx.sendfile = (() => { | ||
var ref = _asyncToGenerator(function* (filePath, options) { | ||
@@ -68,3 +68,3 @@ options = options || {}; | ||
}; | ||
}(); | ||
})(); | ||
return next(); | ||
@@ -71,0 +71,0 @@ }); |
@@ -22,3 +22,3 @@ 'use strict'; | ||
this.router.register('/:controller?/:action?', ['GET', 'HEAD', 'POST'], function () { | ||
this.router.register('/:controller?/:action?', ['GET', 'HEAD', 'POST'], (() => { | ||
var ref = _asyncToGenerator(function* (ctx, next) { | ||
@@ -43,3 +43,3 @@ let controller = ctx.params.controller || service.config('defaultController'); | ||
}; | ||
}()); //end of register | ||
})()); //end of register | ||
}; |
@@ -14,3 +14,3 @@ 'use strict'; | ||
module.exports = function () { | ||
module.exports = (() => { | ||
var ref = _asyncToGenerator(function* () { | ||
@@ -48,3 +48,3 @@ this.loadModels = util.noop; | ||
//扩展模型事件 | ||
['Init', 'Validate', 'Save', 'Remove'].forEach(Action => { | ||
['Init', 'Validate', 'Save', 'Remove'].forEach(function (Action) { | ||
let pre = ext['pre' + Action]; | ||
@@ -75,5 +75,7 @@ if (pre) { | ||
return function loadModels() { | ||
function loadModels() { | ||
return ref.apply(this, arguments); | ||
}; | ||
}(); | ||
} | ||
return loadModels; | ||
})(); |
@@ -42,3 +42,3 @@ 'use strict'; | ||
let index = c.index === false ? false : c.index || 'index.html'; | ||
router.register(prefix, ['GET', 'HEAD'], function () { | ||
router.register(prefix, ['GET', 'HEAD'], (() => { | ||
var ref = _asyncToGenerator(function* (ctx, next) { | ||
@@ -62,5 +62,5 @@ yield next(); | ||
}; | ||
}()); | ||
})()); | ||
}); | ||
} | ||
}; |
@@ -16,3 +16,3 @@ 'use strict'; | ||
module.exports = function () { | ||
module.exports = (() => { | ||
var ref = _asyncToGenerator(function* () { | ||
@@ -42,3 +42,3 @@ this.route = util.noop; | ||
let random = require('string-random'); | ||
app.use(function () { | ||
app.use((() => { | ||
var ref = _asyncToGenerator(function* (ctx, next) { | ||
@@ -108,7 +108,7 @@ ctx.sessionKey = key; | ||
}; | ||
}()); | ||
})()); | ||
} | ||
//upload | ||
app.use(function () { | ||
app.use((() => { | ||
var ref = _asyncToGenerator(function* (ctx, next) { | ||
@@ -125,3 +125,3 @@ ctx.files = {}; | ||
ctx.files = {}; | ||
files.forEach(file => { | ||
files.forEach(function (file) { | ||
let fieldname = file.fieldname; | ||
@@ -145,3 +145,3 @@ if (ctx.files[fieldname]) { | ||
}; | ||
}()); | ||
})()); | ||
yield this.loadAppMiddlewares(); | ||
@@ -230,4 +230,4 @@ } | ||
} | ||
return new Promise((resolve, reject) => { | ||
service.engine.renderFile(path, _.assign({}, ctx.locals, locals), (error, result) => { | ||
return new Promise(function (resolve, reject) { | ||
service.engine.renderFile(path, _.assign({}, ctx.locals, locals), function (error, result) { | ||
if (error) { | ||
@@ -242,3 +242,3 @@ reject(error); | ||
ctx.show = function () { | ||
ctx.show = (() => { | ||
var ref = _asyncToGenerator(function* (template, locals) { | ||
@@ -251,3 +251,3 @@ ctx.body = yield ctx.render(template, locals); | ||
}; | ||
}(); | ||
})(); | ||
@@ -258,5 +258,7 @@ return routes(ctx, next); | ||
return function route() { | ||
function route() { | ||
return ref.apply(this, arguments); | ||
}; | ||
}(); | ||
} | ||
return route; | ||
})(); |
{ | ||
"name": "alaska", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "Componentized and pluggable web framework for Node.js", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
2534
77239
23