limit autoValue to inserts

This commit is contained in:
Sacha Greif 2014-12-05 09:44:50 +09:00
parent 053183f5b5
commit f2736c05c7

View file

@ -148,9 +148,10 @@ postSchemaObject = {
type: Number, type: Number,
optional: true, optional: true,
autoValue: function () { autoValue: function () {
// only use this if status field is not set in the document being updated // only provide a default value
// note: should we use defaultValue instead? // 1) this is an insert operation
if(!this.isSet) // 2) status field is not set in the document being inserted
if(this.isInsert && !this.isSet)
return getSetting('requirePostsApproval', false) ? STATUS_PENDING: STATUS_APPROVED return getSetting('requirePostsApproval', false) ? STATUS_PENDING: STATUS_APPROVED
}, },
autoform: { autoform: {