mirror of
https://gitlab.com/bmcgonag/get_my.git
synced 2026-03-27 00:08:49 +00:00
Updates for async and await - still
This commit is contained in:
parent
febb36d75f
commit
706c5dc3ef
18 changed files with 220 additions and 233 deletions
|
|
@ -12,7 +12,7 @@ Products.allow({
|
|||
});
|
||||
|
||||
Meteor.methods({
|
||||
'add.product' (prodName, prodStore) {
|
||||
async 'add.product' (prodName, prodStore) {
|
||||
check(prodName, String);
|
||||
check(prodStore, [String]);
|
||||
|
||||
|
|
@ -24,24 +24,20 @@ Meteor.methods({
|
|||
|
||||
// first does this product already exist?
|
||||
|
||||
const productIsIn = async() => {
|
||||
let prodExists = await Products.findOneAsync({ prodName: pname });
|
||||
try {
|
||||
if (!prodExists) {
|
||||
return Products.insertAsync({
|
||||
prodName: pname,
|
||||
prodOwner: this.userId,
|
||||
prodStore: prodStore,
|
||||
});
|
||||
}
|
||||
} catch(error) {
|
||||
console.log(" ERROR adding Pdocut: " + error);
|
||||
let prodExists = await Products.findOneAsync({ prodName: pname });
|
||||
try {
|
||||
if (!prodExists) {
|
||||
return await Products.insertAsync({
|
||||
prodName: pname,
|
||||
prodOwner: this.userId,
|
||||
prodStore: prodStore,
|
||||
});
|
||||
}
|
||||
} catch(error) {
|
||||
console.log(" ERROR adding Pdocut: " + error);
|
||||
}
|
||||
let prodIn = productIsIn();
|
||||
return prodIn;
|
||||
},
|
||||
'edit.product' (prodId, prodName, prodStore) {
|
||||
async 'edit.product' (prodId, prodName, prodStore) {
|
||||
check(prodId, String);
|
||||
check(prodName, String);
|
||||
check(prodStore, [String]);
|
||||
|
|
@ -52,20 +48,20 @@ Meteor.methods({
|
|||
|
||||
let pname = prodName.charAt(0).toUpperCase() + prodName.slice(1);
|
||||
|
||||
return Products.updateAsync({ _id: prodId }, {
|
||||
return await Products.updateAsync({ _id: prodId }, {
|
||||
$set: {
|
||||
prodName: pname,
|
||||
prodStore: prodStore,
|
||||
}
|
||||
});
|
||||
},
|
||||
'delete.product' (prodId) {
|
||||
async 'delete.product' (prodId) {
|
||||
check(prodId, String);
|
||||
|
||||
if (!this.userId) {
|
||||
throw new Meteor.Error('You are not allowed to delete products. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return Products.removeAsync({ _id: prodId });
|
||||
return await Products.removeAsync({ _id: prodId });
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue