 module.exports = 
 	models:
 		user: 		User
-		Room: 		Room
-		Bookmark:	Bookmark
-		Msg:		Msg
-		roster:		Roster+		roster:		Roster
+		room: 		Room
+		bookmark:	Bookmark
+		msg:		Msg
			return user != null
		p1.then null, (err) ->
			return false		
		
UserSchema.methods =
	checkPermission: (perm) ->
		q = @model('Tag').find(name: $in: @tags).exec()
		q.then (perms) ->
			_.some perms, (r) ->
				_.some r.permissions, (p) ->
					p = new Permission(p)
					p.implies perm
	checkPermissions: (perms) ->
		promises = _.map perms, (p) ->
			@checkPermission(p)
		Promise.all(promises).done (permitted) ->
			_.all permitted
			
UserSchema.plugin(findOrCreate)
UserSchema.plugin(taggable)
UserSchema.plugin(uniqueValidator)

UserSchema.path('url').set (url) ->

		func(err, res)
				
RoomSchema = new mongoose.Schema
	_id:			{ type: String }
	jid:			{ type: String, required: true, index: {unique: true} }
	name:			{ type: String, required: true, index: {unique: true} }
	privateroom:	{ type: Boolean, default: false }
	createdBy:		{ type: mongoose.Schema.Types.ObjectId, ref: 'User' }
	createdAt:		{ type: Date, default: Date.now }
	updatedBy:		{ type: mongoose.Schema.Types.ObjectId, ref: 'User' }
	updatedAt:		{ type: Date, default: Date.now }
	
RoomSchema.statics =
	search_fields: ->
