Started adding async calls for upgrading to Meteor 3.0. Numerous other fixes.
This commit is contained in:
@@ -2,11 +2,11 @@
|
||||
|
||||
Meteor.methods({
|
||||
// Cleans up all Date objects that don't have a time component. Removes any time component.
|
||||
"cleanDates": function() {
|
||||
"cleanDates": async function() {
|
||||
|
||||
// Update the sales dates.
|
||||
|
||||
let sales = Sales.find({}).fetch();
|
||||
let sales = await Sales.find({}).fetchAsync();
|
||||
|
||||
for(let i = 0; i < sales.length; i++) {
|
||||
if(sales[i].date && _.isDate(sales[i].date)) {
|
||||
@@ -15,7 +15,7 @@ Meteor.methods({
|
||||
console.log("Converted " + sales[i].date + " to " + date);
|
||||
|
||||
// Save to the database.
|
||||
Sales.update(sales[i]._id, {$set: {date}}, function(err, id) {
|
||||
await Sales.updateAsync(sales[i]._id, {$set: {date}}, function(err, id) {
|
||||
if(err) console.log(err);
|
||||
}, {bypassCollection2: true});
|
||||
}
|
||||
@@ -25,7 +25,7 @@ Meteor.methods({
|
||||
|
||||
// Update the product price effective dates.
|
||||
|
||||
let products = Products.find({}).fetch();
|
||||
let products = await Products.find({}).fetchAsync();
|
||||
|
||||
for(let i = 0; i < products.length; i++) {
|
||||
let product = products[i];
|
||||
@@ -48,7 +48,7 @@ Meteor.methods({
|
||||
|
||||
// Save the changes.
|
||||
if(hasChanges) {
|
||||
Products.update(product._id, {$set: {prices}}, function(err, id) {
|
||||
await Products.updateAsync(product._id, {$set: {prices}}, function(err, id) {
|
||||
if(err) console.log(err);
|
||||
}, {validate: false, bypassCollection2: true});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user