 	url:			{ type: String, required: true, index: {unique: true} }
 	username:		{ type: String, required: true }
 	email:			{ type: String }
+	createdAt:		{ type: Date, default: Date.now }
 	
 UserSchema.statics =
 	search_fields: ->

			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) ->

	name:			{ type: String, required: true }
	autoJoin:		{ type: Boolean, default: true }
	createdBy:		{ type: mongoose.Schema.Types.ObjectId, ref: 'User' }
	createdAt:		{ type: Date, default: Date.now }
	
BookmarkSchema.statics =
	search_fields: ->
