-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
28 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
1.0.1 / 2016-02-29 | ||
================== | ||
|
||
* 修复初始化数据seed.js | ||
* 修复七牛API调用和测试 | ||
|
||
|
||
1.0.0 / 2016-01-28 | ||
================== | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
/** | ||
* 初始化数据 | ||
* 管理员用户 | ||
* email: [email protected] | ||
* password: admin | ||
*/ | ||
'use strict'; | ||
|
||
|
@@ -8,13 +11,14 @@ const User = mongoose.model('User'); | |
const Article = mongoose.model('Article'); | ||
const TagCategory = mongoose.model('TagCategory'); | ||
const Tag = mongoose.model('Tag'); | ||
const co = require('co'); | ||
const logger = require('../util/logs').logger; | ||
|
||
//初始化标签,文章,用户 | ||
function initData() { | ||
return function *(next) { | ||
module.exports = function () { | ||
co(function* () { | ||
const userCount = yield User.count(); | ||
if(userCount === 0){ | ||
yield User.remove(); | ||
yield User.create({ | ||
nickname:'admin', | ||
email:'[email protected]', | ||
|
@@ -43,7 +47,6 @@ function initData() { | |
} | ||
const tagCount = yield TagCategory.count(); | ||
if(tagCount === 0){ | ||
yield TagCategory.remove(); | ||
yield Tag.remove(); | ||
const languageCat = yield TagCategory.create({ | ||
name:'language', | ||
|
@@ -107,8 +110,7 @@ function initData() { | |
}); | ||
}); | ||
} | ||
yield next; | ||
} | ||
} | ||
|
||
module.exports = initData | ||
}).catch(function (err) { | ||
logger.debug('Init data error'); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters