orionjs / orioncms

[Old] Orion is an open source framework built on Meteor that makes complex as well as simple apps possible with minimal effort.
http://orionjs.org
MIT License
715 stars 129 forks source link

updatedBy attribute is not optional #410

Open ahmadsholehin opened 8 years ago

ahmadsholehin commented 8 years ago

The "updatedBy" attribute does not autofill when doing SomeSchema.clean( obj ) at the server.

// in model definition
SomeSchema = new SimpleSchema( {
  updatedBy: orion.attribute('updatedBy'),
  createdBy: orion.attribute('createdBy')
} );

// in a method
var obj = {};
SomeSchema.clean( obj, {
  extendAutoValueContext: {
    isInsert: true,
    isUpdate: false,
    isUpsert: false,
    isFromTrustedCode: true
  }
} );

check( obj, SomeSchema ); // check will fail with updatedBy unfilled

Probably because it is not marked as optional, in comparison to createdBy's. See: https://github.com/orionjs/orion/blob/master/packages/attributes/updated-by/updated-by.js#L10 https://github.com/orionjs/orion/blob/master/packages/attributes/created-by/created-by.js#L10

Is there something that I've missed? Is this by design?