-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmongo.js
91 lines (90 loc) · 1.74 KB
/
mongo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
const mongoose = require('mongoose')
mongoose.connect('mongodb://localhost/anonydis',{useNewUrlParser: true})
module.exports = {
Post: mongoose.model('Post', mongoose.Schema({
title: {
type: String,
required: true
},
content: {
type: String,
required: true
},
images: {
type: Array,
required: true
},
postuser: {
type: String,
required: true
},
posttime: {
type: Date,
/* 创建时直接印入时间戳 */
default: Date.now
}
})),
User: mongoose.model('User', mongoose.Schema({
username: {
type: String,
required: true
},
password: {
type: String,
required: true
},
nickname: {
type: String,
required: true
},
gender: {
type: Number,
/* 保密,女,男 */
enum: [-1,0,1],
default: -1
},
age: {
type: Number,
required: false
},
word: {
type: String,
required: false
},
photo: {
type: String,
default: '/img/me.png'
},
posts: {
type: Array,
required: false
},
discuss: {
type: Array,
required: false
},
lastposttime: {
type: Date,
required: false
},
registertime: {
type: Date,
default: Date.now
},
lastlogintime: {
type: Date,
required: false
},
status: {
type: Array,
/* 登录权限,帖子权限,评论权限,聊天权限 */
default: [0,0,0,0]
}
}))
}
// new Post({
// title:'你好啊我来了',
// content: '你好啊我来了你好啊我来了你好啊我来了你好啊我来了你好啊我来了',
// postuser: '小兵旭旭',
// posttime: '2018-9-7'
// }).save()