Created
March 17, 2011 21:26
-
-
Save NuckChorris/875161 to your computer and use it in GitHub Desktop.
Caffeine Database Layer
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
$ node test-mongo-1.js | |
node.js:116 | |
throw e; // process.nextTick error, or 'error' event on first tick | |
^ | |
TypeError: undefined is not a function | |
at CALL_NON_FUNCTION_AS_CONSTRUCTOR (native) | |
at Schema.path (/usr/local/lib/node/.npm/mongoose/1.1.5/package/lib/mongoose/schema.js:139:24) | |
at Schema.add (/usr/local/lib/node/.npm/mongoose/1.1.5/package/lib/mongoose/schema.js:106:12) | |
at new Schema (/usr/local/lib/node/.npm/mongoose/1.1.5/package/lib/mongoose/schema.js:38:10) | |
at Object.<anonymous> (/home/Peter/Server/test-mongo-1.js:10:18) | |
at Module._compile (module.js:373:26) | |
at Object..js (module.js:379:10) | |
at Module.load (module.js:305:31) | |
at Function._load (module.js:271:10) | |
at Array.<anonymous> (module.js:392:10) |
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
var mongoose = require('mongoose'), | |
Schema = mongoose.Schema; | |
var gpcSchema = new Schema({ | |
index : Number, | |
name : String, | |
operator : Boolean, | |
admin : Boolean, | |
}); | |
var UserSchema = new Schema({ | |
name : String, | |
password : String, | |
authtoken : String, | |
uid : String, | |
symbol : String, | |
realname : String, | |
typename : String, | |
gpc : gpcSchema, | |
}); | |
var ChatSchema = new Schema({ | |
name: String, | |
owner: UserSchema, | |
desc: String, | |
}); | |
var PrivclassSchema = new Schema({ | |
room : ChatSchema, | |
name : String, | |
order : { type: Number, min: 1, max: 99 }, | |
admin : Boolean, | |
kick : Boolean, | |
topic : Boolean, | |
title : Boolean, | |
join : Boolean, | |
msg : Boolean, | |
promote : { type: Number, min: -1, max: 99 }, | |
demote : { type: Number, min: -1, max: 99 }, | |
images : { type: Number, min: -1, max: 99 }, | |
smilies : { type: Number, min: -1, max: 99 }, | |
emoticons : { type: Number, min: -1, max: 99 }, | |
thumbs : { type: Number, min: -1, max: 99 }, | |
avatars : { type: Number, min: -1, max: 99 }, | |
websites : { type: Number, min: -1, max: 99 }, | |
objects : { type: Number, min: -1, max: 99 }, | |
members : [UserSchema], | |
}); | |
mongoose.connect('mongo://caffeine:PASSWORD@localhost:27017/Caffeine'); | |
mongoose.model('Chat', ChatSchema); | |
mongoose.model('Privclass', PrivclassSchema); | |
mongoose.model('gpc', gpcSchema); | |
mongoose.model('User', UserSchema); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment