[英]Sails.js: Bootstrap encountered an error
我的/config/bootstrap.js
中有以下代碼,用於插入一些用於開發的虛擬數據。
/* global User */
/* global Category */
var insertDummyUsers = function() {
sails.log.info('Inserting dummy users');
var users = [
{ email: 'test@test.com' },
{ email: 'test1@testdomain.gr' },
{ email: 'test2@cnn.com'}
];
return User.create(users);
};
var insertDummyCategories = function() {
sails.log.info('Inserting dummy categories');
var categories = [
{ name: 'Furniture' },
{ name: 'Lighting' },
{ name: 'Computers' },
{ name: 'Networking' },
{ name: 'Telecommunications' },
{ name: 'TV & Audio' }
];
return Category.create(categories);
};
module.exports.bootstrap = function(cb) {
User.count().then(function(err,count){
if (count > 0) {
cb();
} else {
// Insert some dummy users
insertDummyUsers()
.then(insertDummyCategories)
.then(cb);
}
});
};
當我lift
應用程序時,我得到:
info: Inserting dummy users info: Inserting dummy categories error: Bootstrap encountered an error: see(below) error: [ { name: 'Networking, id: 4, createdAt: ..., updatedAt: ... }] [... so on]
但是,我可以看到數據被保留在數據庫中,但應用程序沒有被解除。
這里發生了什么? 它真的沒有任何線索。
EDIT migrate:
設置為drop
Category模型定義如下:
module.exports = {
attributes: {
name: {
type: 'string'
},
/* Associations */
subcategories: {
collection: 'Subcategory',
via: 'parentCategory'
}
}
};
當我編輯你的創建功能時,我覺得這很奇怪。 即使回調函數為空,它也能工作。
我需要多看一點,但這可能是一個需要報告的錯誤。
return Category.create(categories, function(err, returnModel) {
sails.log.debug('This should work!!! -- Error : ' + err + 'model : ' +
returnModel); });
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.