Fixes #2596 incorrect date types for created & updated

This commit is contained in:
Justin Reynolds 2019-09-05 12:29:45 -05:00
parent 2c78aab3dc
commit 3b9f2ca7c2
22 changed files with 103 additions and 33 deletions

View file

@ -20,6 +20,8 @@ AccountSettings.attachSchema(
autoValue() {
if (this.isInsert) {
return new Date();
} else if (this.isUpsert) {
return { $setOnInsert: new Date() };
} else {
this.unset();
}

View file

@ -14,6 +14,16 @@ Actions.allow({
},
});
Actions.before.insert((userId, doc) => {
doc.createdAt = new Date();
doc.modifiedAt = doc.createdAt;
});
Actions.before.update((userId, doc, fieldNames, modifier) => {
modifier.$set = modifier.$set || {};
modifier.$set.modifiedAt = new Date();
});
Actions.helpers({
description() {
return this.desc;

View file

@ -62,8 +62,14 @@ Activities.helpers({
//},
});
Activities.before.update((userId, doc, fieldNames, modifier) => {
modifier.$set = modifier.$set || {};
modifier.$set.modifiedAt = new Date();
});
Activities.before.insert((userId, doc) => {
doc.createdAt = new Date();
doc.modifiedAt = doc.createdAt;
});
Activities.after.insert((userId, doc) => {

View file

@ -25,6 +25,8 @@ Announcements.attachSchema(
autoValue() {
if (this.isInsert) {
return new Date();
} else if (this.isUpsert) {
return { $setOnInsert: new Date() };
} else {
this.unset();
}

View file

@ -55,6 +55,8 @@ Boards.attachSchema(
autoValue() {
if (this.isInsert) {
return new Date();
} else if (this.isUpsert) {
return { $setOnInsert: new Date() };
} else {
this.unset();
}

View file

@ -34,6 +34,8 @@ CardComments.attachSchema(
autoValue() {
if (this.isInsert) {
return new Date();
} else if (this.isUpsert) {
return { $setOnInsert: new Date() };
} else {
this.unset();
}

View file

@ -107,6 +107,8 @@ Cards.attachSchema(
autoValue() {
if (this.isInsert) {
return new Date();
} else if (this.isUpsert) {
return { $setOnInsert: new Date() };
} else {
this.unset();
}

View file

@ -44,6 +44,8 @@ ChecklistItems.attachSchema(
autoValue() {
if (this.isInsert) {
return new Date();
} else if (this.isUpsert) {
return { $setOnInsert: new Date() };
} else {
this.unset();
}

View file

@ -35,6 +35,8 @@ Checklists.attachSchema(
autoValue() {
if (this.isInsert) {
return new Date();
} else if (this.isUpsert) {
return { $setOnInsert: new Date() };
} else {
this.unset();
}

View file

@ -78,6 +78,8 @@ CustomFields.attachSchema(
autoValue() {
if (this.isInsert) {
return new Date();
} else if (this.isUpsert) {
return { $setOnInsert: new Date() };
} else {
this.unset();
}

View file

@ -63,6 +63,8 @@ Integrations.attachSchema(
autoValue() {
if (this.isInsert) {
return new Date();
} else if (this.isUpsert) {
return { $setOnInsert: new Date() };
} else {
this.unset();
}

View file

@ -18,6 +18,8 @@ InvitationCodes.attachSchema(
autoValue() {
if (this.isInsert) {
return new Date();
} else if (this.isUpsert) {
return { $setOnInsert: new Date() };
} else {
this.unset();
}

View file

@ -45,6 +45,8 @@ Lists.attachSchema(
autoValue() {
if (this.isInsert) {
return new Date();
} else if (this.isUpsert) {
return { $setOnInsert: new Date() };
} else {
this.unset();
}

View file

@ -98,6 +98,8 @@ Org.attachSchema(
autoValue() {
if (this.isInsert) {
return new Date();
} else if (this.isUpsert) {
return { $setOnInsert: new Date() };
} else {
this.unset();
}

View file

@ -49,6 +49,8 @@ OrgUser.attachSchema(
autoValue() {
if (this.isInsert) {
return new Date();
} else if (this.isUpsert) {
return { $setOnInsert: new Date() };
} else {
this.unset();
}

View file

@ -27,6 +27,8 @@ Rules.attachSchema(
autoValue() {
if (this.isInsert) {
return new Date();
} else if (this.isUpsert) {
return { $setOnInsert: new Date() };
} else {
this.unset();
}

View file

@ -60,6 +60,8 @@ Settings.attachSchema(
autoValue() {
if (this.isInsert) {
return new Date();
} else if (this.isUpsert) {
return { $setOnInsert: new Date() };
} else {
this.unset();
}

View file

@ -38,6 +38,8 @@ Swimlanes.attachSchema(
autoValue() {
if (this.isInsert) {
return new Date();
} else if (this.isUpsert) {
return { $setOnInsert: new Date() };
} else {
this.unset();
}

View file

@ -12,6 +12,16 @@ Triggers.mutations({
},
});
Triggers.before.insert((userId, doc) => {
doc.createdAt = new Date();
doc.updatedAt = doc.createdAt;
});
Triggers.before.update((userId, doc, fieldNames, modifier) => {
modifier.$set = modifier.$set || {};
modifier.$set.updatedAt = new Date();
});
Triggers.allow({
insert(userId, doc) {
return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));

View file

@ -29,6 +29,8 @@ UnsavedEditCollection.attachSchema(
autoValue() {
if (this.isInsert) {
return new Date();
} else if (this.isUpsert) {
return { $setOnInsert: new Date() };
} else {
this.unset();
}

View file

@ -54,6 +54,8 @@ Users.attachSchema(
autoValue() {
if (this.isInsert) {
return new Date();
} else if (this.isUpsert) {
return { $setOnInsert: new Date() };
} else {
this.unset();
}