Skip to content

Instantly share code, notes, and snippets.

@jorgegorka
Created June 18, 2015 23:31
Show Gist options
  • Save jorgegorka/69f26c98fe48494538c2 to your computer and use it in GitHub Desktop.
Save jorgegorka/69f26c98fe48494538c2 to your computer and use it in GitHub Desktop.
Messages schema
messageSchema = new SimpleSchema
userId:
type: String
label: 'User'
index: true
optional: true
denyUpdate: true
description:
type: String
label: 'Message text'
index: true
max: 480
denyUpdate: true
chatRoom:
type: String
label: 'Chat Room'
index: true
autoValue: ->
if @isInsert
return 'MainChat'
else if @isUpsert
return $setOnInsert: 'MainChat'
else
@unset()
denyUpdate: true
createdAt:
type: Date
autoValue: ->
if @isInsert
return new Date
else if @isUpsert
return $setOnInsert: new Date()
else
@unset()
denyUpdate: true
optional: false
index: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment