-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmongooseschema.js
44 lines (39 loc) · 1.37 KB
/
mongooseschema.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
var mongoose = require("mongoose");
var Schema = mongoose.Schema;
var ObjectId = Schema.ObjectId;
//http://mongoosejs.com/docs/guide.html
/*
var blogSchema = new Schema({
title: String,
author: String,
body: String,
comments: [{ body: String, date: Date }],
date: { type: Date, default: Date.now },
hidden: Boolean,
meta: {
votes: Number,
favs: Number
}
});
*/
module.exports = function() {
//http://mongoosejs.com/docs/models.html
//Users (Logging In System)
//Messages (backlog for the associated ofuser)
//lastSession is sesseionKey+IP
var Users = new Schema({
username: { type: String , index: {unique: true}},
password: String,
lastSession: {type: String, default: "TECHNICALLYTHISSHOULDNEVERSTAYLIKETHISHOWEVERWHOKNOWSSOIWILLJUSTPUMPITWITHLETTERS"}
});
var Messages = new Schema({
ofuser: String, //Username of who's account this log is associated with
channel: String, //Channel of the message
server: String, //Which server
user: String, //Who said the message
message: String, //Message
date: { type: Date, default: Date.now() } //Defaults to the current time
});
mongoose.model('User', Users); //can instantiate new User()
mongoose.model('Message', Messages); //can instantiate new Message()
};