added update feature

This commit is contained in:
yamanq 2016-02-10 11:58:21 -05:00
parent 7438a6df12
commit fb377b2625

View File

@ -28,12 +28,21 @@ Meteor.methods({
add_button: function(chrome, pre, post) { add_button: function(chrome, pre, post) {
if ((Meteor.user() != undefined) && (Meteor.user().services.google.email in allowed) && !(pre === "")) { if ((Meteor.user() != undefined) && (Meteor.user().services.google.email in allowed) && !(pre === "")) {
mymoment = moment(pre.replace("/", "-"), "MM-DD-YYYY"); mymoment = moment(pre.replace("/", "-"), "MM-DD-YYYY");
thepretext = mymoment.toISOString().split("T")[0];
time = mymoment.format("X");
previous = schedule.find({"pretext": thepretext}).fetch();
if (previous.length > 0) {
entry = previous[0]
schedule.update(entry._id, {"aftertext": post, "pretext": entry.pretext, "timestamp": entry.timestamp});
} else {
schedule.insert({ schedule.insert({
"pretext": mymoment.toISOString().split("T")[0], "pretext": thepretext,
"aftertext": post, "aftertext": post,
"timestamp": mymoment.format("X") "timestamp": time
}); });
} }
}
}, },
remove: function(chrome) { remove: function(chrome) {
if (Meteor.user() != undefined && Meteor.user().services.google.email in allowed) { if (Meteor.user() != undefined && Meteor.user().services.google.email in allowed) {