This repository has been archived by the owner on Jun 4, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
7f9aceb
commit fa5ce47
Showing
11 changed files
with
516 additions
and
282 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 |
---|---|---|
|
@@ -59,3 +59,6 @@ typings/ | |
|
||
# next.js build output | ||
.next | ||
|
||
# VSCode file | ||
.vscode/* |
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,3 +1,3 @@ | ||
rem Setup local database for debug on Windows | ||
rem Setup local database for debug on Windows. | ||
cd ./data | ||
"C:\Program Files\MongoDB\Server\4.0\bin\mongod.exe" --dbpath ./db | ||
"D:\Program Files\MongoDB\bin\mongod.exe" --dbpath ./db |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* 判断特定对象是否已存在。 | ||
* @param {Object} ModelType 对象类型 | ||
* @param {JSON} query 查询条件 | ||
* @returns {Object | Boolean} 存在则返回对象,不存在返回 false | ||
*/ | ||
// TODO: return Object itself. | ||
const existenceVerifier = (ModelType, query) => { | ||
return new Promise(resolve => | ||
ModelType.findOne(query, (err, object) => { | ||
if (err) { | ||
resolve(null); | ||
} else if (object) { | ||
resolve(object); | ||
} else { | ||
resolve(false); | ||
} | ||
}) | ||
); | ||
}; | ||
|
||
module.exports = existenceVerifier; |
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,14 +1,39 @@ | ||
/** | ||
文章示例 | ||
Notice | ||
{ | ||
title: 'Test', | ||
content: 'Hello, world!', | ||
attachments: ['file1.docx', 'file2.docx'], | ||
tags: ['Tutorials'] | ||
createdAt: '2018-05-16T17:01:42.346Z', | ||
createdBy: '张三', | ||
updatedAt: '2018-05-16T17:01:42.346Z', | ||
updatedBy: '张三' | ||
} | ||
*/ | ||
|
||
const mongoose = require("mongoose"); | ||
const autoIncrement = require("mongoose-auto-increment"); | ||
|
||
const articleSchema = new mongoose.Schema( | ||
{ | ||
title: String | ||
title: String, | ||
content: String, | ||
attachments: [String], | ||
tags: [String], | ||
createdAt: { type: Date, default: Date.now }, | ||
createdBy: String, | ||
updatedAt: { type: Date, default: Date.now }, | ||
updatedBy: String | ||
}, | ||
{ | ||
collection: "articles" | ||
} | ||
); | ||
|
||
articleSchema.plugin(autoIncrement.plugin, "Article"); | ||
const Article = mongoose.model("Article", articleSchema); | ||
|
||
module.exports = Article; |
Oops, something went wrong.