Skip to content

Instantly share code, notes, and snippets.

@ryanswrt
Created April 21, 2015 04:31
Show Gist options
  • Save ryanswrt/f084790bc1ced219fadf to your computer and use it in GitHub Desktop.
Save ryanswrt/f084790bc1ced219fadf to your computer and use it in GitHub Desktop.
@ParentSchemaCol = new Meteor.Collection('parentcol')
@SubSchemaCol = new Meteor.Collection('subcol')
subSchema = new SimpleSchema {
autovalue: {
type: Date
autoValue: ->
new Date()
}
value:{
type: String
autoValue: ->
value = this.siblingField('autovalue')
console.log(value)
value?.toUTCString?() ? 'no value'
}
}
parentSchema = new SimpleSchema {
sub: {
type: subSchema
autoValue: ->
{autovalue: new Date()}
}
value:{
type: String
}
}
ParentSchemaCol.attachSchema parentSchema
SubSchemaCol.attachSchema subSchema
parent_id = ParentSchemaCol.insert({value:'Test'}) // Works
ParentSchemaCol.update(parent_id,{$set:{value:'Breaks'}) // Breaks, autoValue in subschema doesn't set
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment