From aaa9b6cbe705c6659779ff2ad9fd03adcfdb88fb Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Wed, 31 Aug 2022 17:20:03 -0300 Subject: [PATCH 01/60] chore: added async to collections --- src/simple-todos/step01/server/main.js | 16 ++++++++-------- src/simple-todos/step12/server/main.js | 9 ++++----- src/simple-todos/step13/server/main.js | 9 ++++----- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/simple-todos/step01/server/main.js b/src/simple-todos/step01/server/main.js index c7df9bd8..5c4e8951 100644 --- a/src/simple-todos/step01/server/main.js +++ b/src/simple-todos/step01/server/main.js @@ -1,29 +1,29 @@ import { Meteor } from 'meteor/meteor'; import { LinksCollection } from '/imports/api/links'; -function insertLink({ title, url }) { - LinksCollection.insert({ title, url, createdAt: new Date() }); +async function insertLink({ title, url }) { + await LinksCollection.insertAsync({ title, url, createdAt: new Date() }); } -Meteor.startup(() => { +Meteor.startup(async () => { // If the Links collection is empty, add some data. - if (LinksCollection.find().count() === 0) { - insertLink({ + if (await LinksCollection.find().countAsync() === 0) { + await insertLink({ title: 'Do the Tutorial', url: 'https://www.meteor.com/tutorials/react/creating-an-app', }); - insertLink({ + await insertLink({ title: 'Follow the Guide', url: 'http://guide.meteor.com', }); - insertLink({ + await insertLink({ title: 'Read the Docs', url: 'https://docs.meteor.com', }); - insertLink({ + await insertLink({ title: 'Discussions', url: 'https://forums.meteor.com', }); diff --git a/src/simple-todos/step12/server/main.js b/src/simple-todos/step12/server/main.js index 49a1e950..2a52ce37 100644 --- a/src/simple-todos/step12/server/main.js +++ b/src/simple-todos/step12/server/main.js @@ -5,8 +5,8 @@ import { ServiceConfiguration } from 'meteor/service-configuration'; import '/imports/api/tasksMethods'; import '/imports/api/tasksPublications'; -const insertTask = (taskText, user) => - TasksCollection.insert({ +const insertTask = async (taskText, user) => + await TasksCollection.insertAsync({ text: taskText, userId: user._id, createdAt: new Date(), @@ -15,7 +15,7 @@ const insertTask = (taskText, user) => const SEED_USERNAME = 'meteorite'; const SEED_PASSWORD = 'password'; -Meteor.startup(() => { +Meteor.startup( async () => { if (!Accounts.findUserByUsername(SEED_USERNAME)) { Accounts.createUser({ username: SEED_USERNAME, @@ -24,8 +24,7 @@ Meteor.startup(() => { } const user = Accounts.findUserByUsername(SEED_USERNAME); - - if (TasksCollection.find().count() === 0) { + if (await TasksCollection.find().countAsync() === 0) { [ 'First Task', 'Second Task', diff --git a/src/simple-todos/step13/server/main.js b/src/simple-todos/step13/server/main.js index 49a1e950..2a52ce37 100644 --- a/src/simple-todos/step13/server/main.js +++ b/src/simple-todos/step13/server/main.js @@ -5,8 +5,8 @@ import { ServiceConfiguration } from 'meteor/service-configuration'; import '/imports/api/tasksMethods'; import '/imports/api/tasksPublications'; -const insertTask = (taskText, user) => - TasksCollection.insert({ +const insertTask = async (taskText, user) => + await TasksCollection.insertAsync({ text: taskText, userId: user._id, createdAt: new Date(), @@ -15,7 +15,7 @@ const insertTask = (taskText, user) => const SEED_USERNAME = 'meteorite'; const SEED_PASSWORD = 'password'; -Meteor.startup(() => { +Meteor.startup( async () => { if (!Accounts.findUserByUsername(SEED_USERNAME)) { Accounts.createUser({ username: SEED_USERNAME, @@ -24,8 +24,7 @@ Meteor.startup(() => { } const user = Accounts.findUserByUsername(SEED_USERNAME); - - if (TasksCollection.find().count() === 0) { + if (await TasksCollection.find().countAsync() === 0) { [ 'First Task', 'Second Task', From 58c914c2763436f5bc6f8f5610ef124014856b59 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Wed, 31 Aug 2022 17:22:19 -0300 Subject: [PATCH 02/60] chore(step02): added async methods --- src/simple-todos/step02/server/main.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/simple-todos/step02/server/main.js b/src/simple-todos/step02/server/main.js index cd5ce507..ed90033b 100644 --- a/src/simple-todos/step02/server/main.js +++ b/src/simple-todos/step02/server/main.js @@ -1,10 +1,11 @@ import { Meteor } from 'meteor/meteor'; import { TasksCollection } from '/imports/api/TasksCollection'; -const insertTask = taskText => TasksCollection.insert({ text: taskText }); +const insertTask = + async (taskText) => TasksCollection.insertAsync({ text: taskText }); -Meteor.startup(() => { - if (TasksCollection.find().count() === 0) { +Meteor.startup(async () => { + if (await TasksCollection.find().countAsync() === 0) { [ 'First Task', 'Second Task', From 3d82d57678aabbb0d7f5269353946c22080384d0 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Wed, 31 Aug 2022 17:31:29 -0300 Subject: [PATCH 03/60] chore(step03):updated ui --- src/simple-todos/step03/imports/ui/App.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/simple-todos/step03/imports/ui/App.jsx b/src/simple-todos/step03/imports/ui/App.jsx index 5f5209d2..32534e12 100644 --- a/src/simple-todos/step03/imports/ui/App.jsx +++ b/src/simple-todos/step03/imports/ui/App.jsx @@ -5,8 +5,8 @@ import { Task } from './Task'; import { TaskForm } from './TaskForm'; export const App = () => { - const tasks = useTracker(() => - TasksCollection.find({}, { sort: { createdAt: -1 } }).fetch() + const tasks = useTracker(async () => + await TasksCollection.find({}, { sort: { createdAt: -1 } }).fetchAsync() ); return ( From 9bca17a4d0326c5233ea319a1fe1592cf4508e67 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Wed, 31 Aug 2022 17:31:45 -0300 Subject: [PATCH 04/60] chore(step03):updated server --- src/simple-todos/step03/server/main.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/simple-todos/step03/server/main.js b/src/simple-todos/step03/server/main.js index cd5ce507..ed90033b 100644 --- a/src/simple-todos/step03/server/main.js +++ b/src/simple-todos/step03/server/main.js @@ -1,10 +1,11 @@ import { Meteor } from 'meteor/meteor'; import { TasksCollection } from '/imports/api/TasksCollection'; -const insertTask = taskText => TasksCollection.insert({ text: taskText }); +const insertTask = + async (taskText) => TasksCollection.insertAsync({ text: taskText }); -Meteor.startup(() => { - if (TasksCollection.find().count() === 0) { +Meteor.startup(async () => { + if (await TasksCollection.find().countAsync() === 0) { [ 'First Task', 'Second Task', From 64a4b37be846b82e28489baa999b08d93a4900cc Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Wed, 31 Aug 2022 17:56:18 -0300 Subject: [PATCH 05/60] chore(step04-client): added async methods --- src/simple-todos/step04/imports/ui/App.jsx | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/simple-todos/step04/imports/ui/App.jsx b/src/simple-todos/step04/imports/ui/App.jsx index f5c4c4b3..4b3fa641 100644 --- a/src/simple-todos/step04/imports/ui/App.jsx +++ b/src/simple-todos/step04/imports/ui/App.jsx @@ -4,19 +4,21 @@ import { TasksCollection } from '/imports/api/TasksCollection'; import { Task } from './Task'; import { TaskForm } from './TaskForm'; -const toggleChecked = ({ _id, isChecked }) => { - TasksCollection.update(_id, { - $set: { - isChecked: !isChecked, - }, - }); -}; +const toggleChecked = + async ({ _id, isChecked }) => { + await TasksCollection.updateAsync(_id, { + $set: { + isChecked: !isChecked, + }, + }); + }; -const deleteTask = ({ _id }) => TasksCollection.remove(_id); +const deleteTask = + async ({ _id }) => TasksCollection.removeAsync(_id); export const App = () => { - const tasks = useTracker(() => - TasksCollection.find({}, { sort: { createdAt: -1 } }).fetch() + const tasks = useTracker(async () => + await TasksCollection.find({}, { sort: { createdAt: -1 } }).fetchAsync() ); return ( From 531e45af2170286d52367ad9ed733d6096744c7e Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Wed, 31 Aug 2022 17:56:45 -0300 Subject: [PATCH 06/60] chore(step04-server): added async methods --- src/simple-todos/step04/server/main.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/simple-todos/step04/server/main.js b/src/simple-todos/step04/server/main.js index cd5ce507..ed90033b 100644 --- a/src/simple-todos/step04/server/main.js +++ b/src/simple-todos/step04/server/main.js @@ -1,10 +1,11 @@ import { Meteor } from 'meteor/meteor'; import { TasksCollection } from '/imports/api/TasksCollection'; -const insertTask = taskText => TasksCollection.insert({ text: taskText }); +const insertTask = + async (taskText) => TasksCollection.insertAsync({ text: taskText }); -Meteor.startup(() => { - if (TasksCollection.find().count() === 0) { +Meteor.startup(async () => { + if (await TasksCollection.find().countAsync() === 0) { [ 'First Task', 'Second Task', From 2a781c26e4a0762626ad0ece52ad7dc54c693697 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Wed, 31 Aug 2022 18:15:38 -0300 Subject: [PATCH 07/60] chore(step05-client): added async methods --- src/simple-todos/step05/imports/ui/App.jsx | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/simple-todos/step05/imports/ui/App.jsx b/src/simple-todos/step05/imports/ui/App.jsx index 6becb2a4..ea12d8b0 100644 --- a/src/simple-todos/step05/imports/ui/App.jsx +++ b/src/simple-todos/step05/imports/ui/App.jsx @@ -4,21 +4,24 @@ import { TasksCollection } from '/imports/api/TasksCollection'; import { Task } from './Task'; import { TaskForm } from './TaskForm'; -const toggleChecked = ({ _id, isChecked }) => { - TasksCollection.update(_id, { - $set: { - isChecked: !isChecked, - }, - }); -}; +const toggleChecked = + async ({ _id, isChecked }) => { + await TasksCollection.updateAsync(_id, { + $set: { + isChecked: !isChecked, + }, + }); + }; -const deleteTask = ({ _id }) => TasksCollection.remove(_id); +const deleteTask = + async ({ _id }) => TasksCollection.removeAsync(_id); export const App = () => { - const tasks = useTracker(() => - TasksCollection.find({}, { sort: { createdAt: -1 } }).fetch() + const tasks = useTracker(async () => + await TasksCollection.find({}, { sort: { createdAt: -1 } }).fetchAsync() ); + return (
From f2213d66d668baba082e2f16776a98c279441a97 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Wed, 31 Aug 2022 18:16:03 -0300 Subject: [PATCH 08/60] chore(step05-server): added async methods --- src/simple-todos/step05/server/main.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/simple-todos/step05/server/main.js b/src/simple-todos/step05/server/main.js index cd5ce507..ed90033b 100644 --- a/src/simple-todos/step05/server/main.js +++ b/src/simple-todos/step05/server/main.js @@ -1,10 +1,11 @@ import { Meteor } from 'meteor/meteor'; import { TasksCollection } from '/imports/api/TasksCollection'; -const insertTask = taskText => TasksCollection.insert({ text: taskText }); +const insertTask = + async (taskText) => TasksCollection.insertAsync({ text: taskText }); -Meteor.startup(() => { - if (TasksCollection.find().count() === 0) { +Meteor.startup(async () => { + if (await TasksCollection.find().countAsync() === 0) { [ 'First Task', 'Second Task', From 47d8a1d502adb5ad2de277e7e32653258f10cc78 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Wed, 31 Aug 2022 18:32:45 -0300 Subject: [PATCH 09/60] chore(step06-client):added async methods --- src/simple-todos/step06/imports/ui/App.jsx | 28 ++++++++++++---------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/simple-todos/step06/imports/ui/App.jsx b/src/simple-todos/step06/imports/ui/App.jsx index fb1c42d5..51e9b86c 100644 --- a/src/simple-todos/step06/imports/ui/App.jsx +++ b/src/simple-todos/step06/imports/ui/App.jsx @@ -4,29 +4,31 @@ import { TasksCollection } from '/imports/api/TasksCollection'; import { Task } from './Task'; import { TaskForm } from './TaskForm'; -const toggleChecked = ({ _id, isChecked }) => { - TasksCollection.update(_id, { - $set: { - isChecked: !isChecked, - }, - }); -}; +const toggleChecked = + async ({ _id, isChecked }) => { + await TasksCollection.updateAsync(_id, { + $set: { + isChecked: !isChecked, + }, + }); + }; -const deleteTask = ({ _id }) => TasksCollection.remove(_id); +const deleteTask = + async ({ _id }) => TasksCollection.removeAsync(_id); export const App = () => { const [hideCompleted, setHideCompleted] = useState(false); const hideCompletedFilter = { isChecked: { $ne: true } }; - const tasks = useTracker(() => - TasksCollection.find(hideCompleted ? hideCompletedFilter : {}, { + const tasks = useTracker(async () => + await TasksCollection.find(hideCompleted ? hideCompletedFilter : {}, { sort: { createdAt: -1 }, - }).fetch() + }).fetchAsync() ); - const pendingTasksCount = useTracker(() => - TasksCollection.find(hideCompletedFilter).count() + const pendingTasksCount = useTracker(async () => + await TasksCollection.find(hideCompletedFilter).countAsync() ); const pendingTasksTitle = `${ From af72bac61b7989f1ba9a672d24f8e3ad97cbdd8e Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Wed, 31 Aug 2022 18:33:29 -0300 Subject: [PATCH 10/60] chore(step06-server):added async methods --- src/simple-todos/step06/server/main.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/simple-todos/step06/server/main.js b/src/simple-todos/step06/server/main.js index cd5ce507..ed90033b 100644 --- a/src/simple-todos/step06/server/main.js +++ b/src/simple-todos/step06/server/main.js @@ -1,10 +1,11 @@ import { Meteor } from 'meteor/meteor'; import { TasksCollection } from '/imports/api/TasksCollection'; -const insertTask = taskText => TasksCollection.insert({ text: taskText }); +const insertTask = + async (taskText) => TasksCollection.insertAsync({ text: taskText }); -Meteor.startup(() => { - if (TasksCollection.find().count() === 0) { +Meteor.startup(async () => { + if (await TasksCollection.find().countAsync() === 0) { [ 'First Task', 'Second Task', From 598f2639ac6675d90e9db092acfe1d679906e0e5 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 10:00:18 -0300 Subject: [PATCH 11/60] chore(step07): updated app.jsx --- src/simple-todos/step07/imports/ui/App.jsx | 28 ++++++++++++---------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/simple-todos/step07/imports/ui/App.jsx b/src/simple-todos/step07/imports/ui/App.jsx index 2d9e2a3c..69130256 100644 --- a/src/simple-todos/step07/imports/ui/App.jsx +++ b/src/simple-todos/step07/imports/ui/App.jsx @@ -6,15 +6,17 @@ import { Task } from './Task'; import { TaskForm } from './TaskForm'; import { LoginForm } from './LoginForm'; -const toggleChecked = ({ _id, isChecked }) => { - TasksCollection.update(_id, { - $set: { - isChecked: !isChecked, - }, - }); -}; - -const deleteTask = ({ _id }) => TasksCollection.remove(_id); +const toggleChecked = + async ({ _id, isChecked }) => { + await TasksCollection.updateAsync(_id, { + $set: { + isChecked: !isChecked, + }, + }); + }; + +const deleteTask = + async ({ _id }) => TasksCollection.removeAsync(_id); export const App = () => { const user = useTracker(() => Meteor.user()); @@ -27,7 +29,7 @@ export const App = () => { const pendingOnlyFilter = { ...hideCompletedFilter, ...userFilter }; - const tasks = useTracker(() => { + const tasks = useTracker(async () => { if (!user) { return []; } @@ -37,15 +39,15 @@ export const App = () => { { sort: { createdAt: -1 }, } - ).fetch(); + ).fetchAsync(); }); - const pendingTasksCount = useTracker(() => { + const pendingTasksCount = useTracker(async () => { if (!user) { return 0; } - return TasksCollection.find(pendingOnlyFilter).count(); + return TasksCollection.find(pendingOnlyFilter).countAsync(); }); const pendingTasksTitle = `${ From f2b31a332a3bc792c0dd187e501fcdf5d7ddae90 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 10:00:29 -0300 Subject: [PATCH 12/60] chore(step07): updated taskform.jsx --- src/simple-todos/step07/imports/ui/TaskForm.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/simple-todos/step07/imports/ui/TaskForm.jsx b/src/simple-todos/step07/imports/ui/TaskForm.jsx index ae389060..b7f257f2 100644 --- a/src/simple-todos/step07/imports/ui/TaskForm.jsx +++ b/src/simple-todos/step07/imports/ui/TaskForm.jsx @@ -4,12 +4,12 @@ import { TasksCollection } from '/imports/api/TasksCollection'; export const TaskForm = ({user}) => { const [text, setText] = useState(''); - const handleSubmit = e => { + const handleSubmit = async (e) => { e.preventDefault(); if (!text) return; - TasksCollection.insert({ + await TasksCollection.insertAsync({ text: text.trim(), createdAt: new Date(), userId: user._id From 36dea7f226abe82b7db9c0b8b6688b0ee056cfe8 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 10:00:45 -0300 Subject: [PATCH 13/60] chore(step07): updated server --- src/simple-todos/step07/server/main.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/simple-todos/step07/server/main.js b/src/simple-todos/step07/server/main.js index cea2c265..b6025985 100644 --- a/src/simple-todos/step07/server/main.js +++ b/src/simple-todos/step07/server/main.js @@ -2,8 +2,8 @@ import { Meteor } from 'meteor/meteor'; import { Accounts } from 'meteor/accounts-base'; import { TasksCollection } from '/imports/api/TasksCollection'; -const insertTask = (taskText, user) => - TasksCollection.insert({ +const insertTask = async (taskText, user) => + await TasksCollection.insertAsync({ text: taskText, userId: user._id, createdAt: new Date(), @@ -12,7 +12,7 @@ const insertTask = (taskText, user) => const SEED_USERNAME = 'meteorite'; const SEED_PASSWORD = 'password'; -Meteor.startup(() => { +Meteor.startup( async () => { if (!Accounts.findUserByUsername(SEED_USERNAME)) { Accounts.createUser({ username: SEED_USERNAME, @@ -21,8 +21,7 @@ Meteor.startup(() => { } const user = Accounts.findUserByUsername(SEED_USERNAME); - - if (TasksCollection.find().count() === 0) { + if (await TasksCollection.find().countAsync() === 0) { [ 'First Task', 'Second Task', @@ -31,6 +30,6 @@ Meteor.startup(() => { 'Fifth Task', 'Sixth Task', 'Seventh Task', - ].forEach(taskText => insertTask(taskText, user)); + ].forEach(insertTask); } }); From 65cbd1fbc2e7ed5091af96652be0b1ada617e86b Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 10:39:06 -0300 Subject: [PATCH 14/60] chore(step08): updated app.jsx --- src/simple-todos/step08/imports/ui/App.jsx | 28 ++++++++++++---------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/simple-todos/step08/imports/ui/App.jsx b/src/simple-todos/step08/imports/ui/App.jsx index d21d8ccd..a0982996 100644 --- a/src/simple-todos/step08/imports/ui/App.jsx +++ b/src/simple-todos/step08/imports/ui/App.jsx @@ -6,15 +6,17 @@ import { Task } from './Task'; import { TaskForm } from './TaskForm'; import { LoginForm } from './LoginForm'; -const toggleChecked = ({ _id, isChecked }) => { - TasksCollection.update(_id, { - $set: { - isChecked: !isChecked, - }, - }); -}; - -const deleteTask = ({ _id }) => TasksCollection.remove(_id); +const toggleChecked = + async ({ _id, isChecked }) => { + await TasksCollection.updateAsync(_id, { + $set: { + isChecked: !isChecked, + }, + }); + }; + +const deleteTask = + async ({ _id }) => TasksCollection.removeAsync(_id); export const App = () => { const user = useTracker(() => Meteor.user()); @@ -27,7 +29,7 @@ export const App = () => { const pendingOnlyFilter = { ...hideCompletedFilter, ...userFilter }; - const tasks = useTracker(() => { + const tasks = useTracker(async () => { if (!user) { return []; } @@ -37,15 +39,15 @@ export const App = () => { { sort: { createdAt: -1 }, } - ).fetch(); + ).fetchAsync(); }); - const pendingTasksCount = useTracker(() => { + const pendingTasksCount = useTracker(async () => { if (!user) { return 0; } - return TasksCollection.find(pendingOnlyFilter).count(); + return await TasksCollection.find(pendingOnlyFilter).countAsync(); }); const pendingTasksTitle = `${ From eba7ee2ee6c6f829f11ee4e92015e97db985fba1 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 10:39:36 -0300 Subject: [PATCH 15/60] chore(step08): updated TaskForm.jsx --- src/simple-todos/step08/imports/ui/TaskForm.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/simple-todos/step08/imports/ui/TaskForm.jsx b/src/simple-todos/step08/imports/ui/TaskForm.jsx index ae389060..b7f257f2 100644 --- a/src/simple-todos/step08/imports/ui/TaskForm.jsx +++ b/src/simple-todos/step08/imports/ui/TaskForm.jsx @@ -4,12 +4,12 @@ import { TasksCollection } from '/imports/api/TasksCollection'; export const TaskForm = ({user}) => { const [text, setText] = useState(''); - const handleSubmit = e => { + const handleSubmit = async (e) => { e.preventDefault(); if (!text) return; - TasksCollection.insert({ + await TasksCollection.insertAsync({ text: text.trim(), createdAt: new Date(), userId: user._id From 1a241fcc889a4b976b30b1e5f064e4ee48b96f5a Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 10:40:21 -0300 Subject: [PATCH 16/60] chore(step08): updated server/main.js --- src/simple-todos/step08/server/main.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/simple-todos/step08/server/main.js b/src/simple-todos/step08/server/main.js index b7be0ec7..5bab51a5 100644 --- a/src/simple-todos/step08/server/main.js +++ b/src/simple-todos/step08/server/main.js @@ -3,8 +3,8 @@ import { Accounts } from 'meteor/accounts-base'; import { TasksCollection } from '/imports/api/TasksCollection'; import { ServiceConfiguration } from 'meteor/service-configuration'; -const insertTask = (taskText, user) => - TasksCollection.insert({ +const insertTask = async (taskText, user) => + await TasksCollection.insertAsync({ text: taskText, userId: user._id, createdAt: new Date(), @@ -13,7 +13,7 @@ const insertTask = (taskText, user) => const SEED_USERNAME = 'meteorite'; const SEED_PASSWORD = 'password'; -Meteor.startup(() => { +Meteor.startup( async () => { if (!Accounts.findUserByUsername(SEED_USERNAME)) { Accounts.createUser({ username: SEED_USERNAME, @@ -22,8 +22,7 @@ Meteor.startup(() => { } const user = Accounts.findUserByUsername(SEED_USERNAME); - - if (TasksCollection.find().count() === 0) { + if (await TasksCollection.find().countAsync() === 0) { [ 'First Task', 'Second Task', @@ -41,8 +40,8 @@ ServiceConfiguration.configurations.upsert( { $set: { loginStyle: 'popup', - clientId: '4b9f9c09485b4bba83ba', // insert your clientId here - secret: 'f9205f6f03b6c45547e70efe1171dbe0409440df', // insert your secret here + clientId: '', // insert your clientId here + secret: '', // insert your secret here }, } ); From 5e3fa37db5049fc9891142a0bfc23b07ca69a8cf Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 11:15:00 -0300 Subject: [PATCH 17/60] chore(step08): update on app.jsx --- src/simple-todos/step08/imports/ui/App.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/simple-todos/step08/imports/ui/App.jsx b/src/simple-todos/step08/imports/ui/App.jsx index a0982996..c4278465 100644 --- a/src/simple-todos/step08/imports/ui/App.jsx +++ b/src/simple-todos/step08/imports/ui/App.jsx @@ -34,7 +34,7 @@ export const App = () => { return []; } - return TasksCollection.find( + return await TasksCollection.find( hideCompleted ? pendingOnlyFilter : userFilter, { sort: { createdAt: -1 }, From 2f64dd17cf6c154fe3dfba5d45acbf6b243fa796 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 11:15:49 -0300 Subject: [PATCH 18/60] chore(step09): update taskMethods.js --- src/simple-todos/step09/imports/api/tasksMethods.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/simple-todos/step09/imports/api/tasksMethods.js b/src/simple-todos/step09/imports/api/tasksMethods.js index 2066527b..84367134 100644 --- a/src/simple-todos/step09/imports/api/tasksMethods.js +++ b/src/simple-todos/step09/imports/api/tasksMethods.js @@ -3,31 +3,31 @@ import { check } from 'meteor/check'; import { TasksCollection } from '/imports/db/TasksCollection'; Meteor.methods({ - 'tasks.insert'(text) { + async 'tasks.insert'(text) { check(text, String); if (!this.userId) { throw new Meteor.Error('Not authorized.'); } - TasksCollection.insert({ + await TasksCollection.insertAsync({ text, createdAt: new Date(), userId: this.userId, }); }, - 'tasks.remove'(taskId) { + async 'tasks.remove'(taskId) { check(taskId, String); if (!this.userId) { throw new Meteor.Error('Not authorized.'); } - TasksCollection.remove(taskId); + await TasksCollection.removeAsync(taskId); }, - 'tasks.setIsChecked'(taskId, isChecked) { + async 'tasks.setIsChecked'(taskId, isChecked) { check(taskId, String); check(isChecked, Boolean); @@ -35,7 +35,7 @@ Meteor.methods({ throw new Meteor.Error('Not authorized.'); } - TasksCollection.update(taskId, { + await TasksCollection.updateAsync(taskId, { $set: { isChecked, }, From b4c8055e8773530274a2bc2c7ded205f70b7adc2 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 11:16:21 -0300 Subject: [PATCH 19/60] chore(step09): update app.jsx --- src/simple-todos/step09/imports/ui/App.jsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/simple-todos/step09/imports/ui/App.jsx b/src/simple-todos/step09/imports/ui/App.jsx index 3819db69..e58132a4 100644 --- a/src/simple-todos/step09/imports/ui/App.jsx +++ b/src/simple-todos/step09/imports/ui/App.jsx @@ -22,25 +22,25 @@ export const App = () => { const pendingOnlyFilter = { ...hideCompletedFilter, ...userFilter }; - const tasks = useTracker(() => { + const tasks = useTracker(async () => { if (!user) { return []; } - return TasksCollection.find( + return await TasksCollection.find( hideCompleted ? pendingOnlyFilter : userFilter, { sort: { createdAt: -1 }, } - ).fetch(); + ).fetchAsync(); }); - const pendingTasksCount = useTracker(() => { + const pendingTasksCount = useTracker(async () => { if (!user) { return 0; } - return TasksCollection.find(pendingOnlyFilter).count(); + return await TasksCollection.find(pendingOnlyFilter).countAsync(); }); const pendingTasksTitle = `${ From 61d6b0e20f01b7c66a5d9cd6b6d989d23112c2b4 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 11:16:43 -0300 Subject: [PATCH 20/60] chore(step09): update taskForm.jsx --- src/simple-todos/step09/imports/ui/TaskForm.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/simple-todos/step09/imports/ui/TaskForm.jsx b/src/simple-todos/step09/imports/ui/TaskForm.jsx index 3d990238..4fe05a0c 100644 --- a/src/simple-todos/step09/imports/ui/TaskForm.jsx +++ b/src/simple-todos/step09/imports/ui/TaskForm.jsx @@ -4,7 +4,7 @@ import React, { useState } from 'react'; export const TaskForm = () => { const [text, setText] = useState(''); - const handleSubmit = e => { + const handleSubmit = async (e) => { e.preventDefault(); if (!text) return; From bdbb43417835f34c426f6733e9d34014b4b56689 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 11:17:00 -0300 Subject: [PATCH 21/60] chore(step09): update server.js --- src/simple-todos/step09/server/main.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/simple-todos/step09/server/main.js b/src/simple-todos/step09/server/main.js index de0881f2..4c85bd16 100644 --- a/src/simple-todos/step09/server/main.js +++ b/src/simple-todos/step09/server/main.js @@ -4,8 +4,8 @@ import { TasksCollection } from '/imports/db/TasksCollection'; import { ServiceConfiguration } from 'meteor/service-configuration'; import '/imports/api/tasksMethods'; -const insertTask = (taskText, user) => - TasksCollection.insert({ +const insertTask = async (taskText, user) => + await TasksCollection.insertAsync({ text: taskText, userId: user._id, createdAt: new Date(), @@ -14,7 +14,7 @@ const insertTask = (taskText, user) => const SEED_USERNAME = 'meteorite'; const SEED_PASSWORD = 'password'; -Meteor.startup(() => { +Meteor.startup( async () => { if (!Accounts.findUserByUsername(SEED_USERNAME)) { Accounts.createUser({ username: SEED_USERNAME, @@ -23,8 +23,7 @@ Meteor.startup(() => { } const user = Accounts.findUserByUsername(SEED_USERNAME); - - if (TasksCollection.find().count() === 0) { + if (await TasksCollection.find().countAsync() === 0) { [ 'First Task', 'Second Task', From 461bd87fe3d9e7aa3eb99b4fa6afd32a815329ba Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 13:50:45 -0300 Subject: [PATCH 22/60] chore(step10): update taskMethods.js --- .../step10/imports/api/tasksMethods.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/simple-todos/step10/imports/api/tasksMethods.js b/src/simple-todos/step10/imports/api/tasksMethods.js index 7b72b959..f4a93d82 100644 --- a/src/simple-todos/step10/imports/api/tasksMethods.js +++ b/src/simple-todos/step10/imports/api/tasksMethods.js @@ -3,37 +3,37 @@ import { check } from 'meteor/check'; import { TasksCollection } from '/imports/db/TasksCollection'; Meteor.methods({ - 'tasks.insert'(text) { + async 'tasks.insert'(text) { check(text, String); if (!this.userId) { throw new Meteor.Error('Not authorized.'); } - TasksCollection.insert({ + await TasksCollection.insertAsync({ text, createdAt: new Date(), userId: this.userId, }); }, - 'tasks.remove'(taskId) { + async 'tasks.remove'(taskId) { check(taskId, String); if (!this.userId) { throw new Meteor.Error('Not authorized.'); } - const task = TasksCollection.findOne({ _id: taskId, userId: this.userId }); + const task = await TasksCollection.findOneAsync({ _id: taskId, userId: this.userId }); if (!task) { throw new Meteor.Error('Access denied.'); } - TasksCollection.remove(taskId); + await TasksCollection.removeAsync(taskId); }, - 'tasks.setIsChecked'(taskId, isChecked) { + async 'tasks.setIsChecked'(taskId, isChecked) { check(taskId, String); check(isChecked, Boolean); @@ -41,13 +41,13 @@ Meteor.methods({ throw new Meteor.Error('Not authorized.'); } - const task = TasksCollection.findOne({ _id: taskId, userId: this.userId }); + const task = await TasksCollection.findOneAsync({ _id: taskId, userId: this.userId }); if (!task) { throw new Meteor.Error('Access denied.'); } - TasksCollection.update(taskId, { + await TasksCollection.updateAsync(taskId, { $set: { isChecked, }, From 17710c7506454c3117fcbe158d1acd9d440d81a9 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 13:50:56 -0300 Subject: [PATCH 23/60] chore(step10): update app.jsx --- src/simple-todos/step10/imports/ui/App.jsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/simple-todos/step10/imports/ui/App.jsx b/src/simple-todos/step10/imports/ui/App.jsx index 45eb54e9..709659ce 100644 --- a/src/simple-todos/step10/imports/ui/App.jsx +++ b/src/simple-todos/step10/imports/ui/App.jsx @@ -22,7 +22,7 @@ export const App = () => { const pendingOnlyFilter = { ...hideCompletedFilter, ...userFilter }; - const { tasks, pendingTasksCount, isLoading } = useTracker(() => { + const { tasks, pendingTasksCount, isLoading } = useTracker(async () => { const noDataAvailable = { tasks: [], pendingTasksCount: 0 }; if (!Meteor.user()) { return noDataAvailable; @@ -33,13 +33,14 @@ export const App = () => { return { ...noDataAvailable, isLoading: true }; } - const tasks = TasksCollection.find( + const tasks = await TasksCollection.find( hideCompleted ? pendingOnlyFilter : userFilter, { sort: { createdAt: -1 }, } - ).fetch(); - const pendingTasksCount = TasksCollection.find(pendingOnlyFilter).count(); + ).fetchAsync(); + const pendingTasksCount = await TasksCollection.find(pendingOnlyFilter) + .countAsync(); return { tasks, pendingTasksCount }; }); From e59e3f479f9e42ba93ed8d9abf6dedc6fa4b1214 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 13:51:05 -0300 Subject: [PATCH 24/60] chore(step10): update taskForm.jsx --- src/simple-todos/step10/imports/ui/TaskForm.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/simple-todos/step10/imports/ui/TaskForm.jsx b/src/simple-todos/step10/imports/ui/TaskForm.jsx index 3d990238..4fe05a0c 100644 --- a/src/simple-todos/step10/imports/ui/TaskForm.jsx +++ b/src/simple-todos/step10/imports/ui/TaskForm.jsx @@ -4,7 +4,7 @@ import React, { useState } from 'react'; export const TaskForm = () => { const [text, setText] = useState(''); - const handleSubmit = e => { + const handleSubmit = async (e) => { e.preventDefault(); if (!text) return; From 2ebe384834d553216ff03e0263ae92c6dd9d4eb7 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 15:34:36 -0300 Subject: [PATCH 25/60] chore(step10): update main.js --- src/simple-todos/step10/server/main.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/simple-todos/step10/server/main.js b/src/simple-todos/step10/server/main.js index 49a1e950..2a52ce37 100644 --- a/src/simple-todos/step10/server/main.js +++ b/src/simple-todos/step10/server/main.js @@ -5,8 +5,8 @@ import { ServiceConfiguration } from 'meteor/service-configuration'; import '/imports/api/tasksMethods'; import '/imports/api/tasksPublications'; -const insertTask = (taskText, user) => - TasksCollection.insert({ +const insertTask = async (taskText, user) => + await TasksCollection.insertAsync({ text: taskText, userId: user._id, createdAt: new Date(), @@ -15,7 +15,7 @@ const insertTask = (taskText, user) => const SEED_USERNAME = 'meteorite'; const SEED_PASSWORD = 'password'; -Meteor.startup(() => { +Meteor.startup( async () => { if (!Accounts.findUserByUsername(SEED_USERNAME)) { Accounts.createUser({ username: SEED_USERNAME, @@ -24,8 +24,7 @@ Meteor.startup(() => { } const user = Accounts.findUserByUsername(SEED_USERNAME); - - if (TasksCollection.find().count() === 0) { + if (await TasksCollection.find().countAsync() === 0) { [ 'First Task', 'Second Task', From 137a7e09cc3f10f3e014c11ee2df6e713f6c943e Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 15:35:11 -0300 Subject: [PATCH 26/60] chore(step11): updated taskMethods.js --- .../step11/imports/api/tasksMethods.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/simple-todos/step11/imports/api/tasksMethods.js b/src/simple-todos/step11/imports/api/tasksMethods.js index 7b72b959..f4a93d82 100644 --- a/src/simple-todos/step11/imports/api/tasksMethods.js +++ b/src/simple-todos/step11/imports/api/tasksMethods.js @@ -3,37 +3,37 @@ import { check } from 'meteor/check'; import { TasksCollection } from '/imports/db/TasksCollection'; Meteor.methods({ - 'tasks.insert'(text) { + async 'tasks.insert'(text) { check(text, String); if (!this.userId) { throw new Meteor.Error('Not authorized.'); } - TasksCollection.insert({ + await TasksCollection.insertAsync({ text, createdAt: new Date(), userId: this.userId, }); }, - 'tasks.remove'(taskId) { + async 'tasks.remove'(taskId) { check(taskId, String); if (!this.userId) { throw new Meteor.Error('Not authorized.'); } - const task = TasksCollection.findOne({ _id: taskId, userId: this.userId }); + const task = await TasksCollection.findOneAsync({ _id: taskId, userId: this.userId }); if (!task) { throw new Meteor.Error('Access denied.'); } - TasksCollection.remove(taskId); + await TasksCollection.removeAsync(taskId); }, - 'tasks.setIsChecked'(taskId, isChecked) { + async 'tasks.setIsChecked'(taskId, isChecked) { check(taskId, String); check(isChecked, Boolean); @@ -41,13 +41,13 @@ Meteor.methods({ throw new Meteor.Error('Not authorized.'); } - const task = TasksCollection.findOne({ _id: taskId, userId: this.userId }); + const task = await TasksCollection.findOneAsync({ _id: taskId, userId: this.userId }); if (!task) { throw new Meteor.Error('Access denied.'); } - TasksCollection.update(taskId, { + await TasksCollection.updateAsync(taskId, { $set: { isChecked, }, From dad0c32042927cf1fe45c13b8c5fa59d0b20535a Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 15:35:23 -0300 Subject: [PATCH 27/60] chore(step11): updated loginForm.jsx --- src/simple-todos/step11/imports/ui/LoginForm.jsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/simple-todos/step11/imports/ui/LoginForm.jsx b/src/simple-todos/step11/imports/ui/LoginForm.jsx index 3b814fc9..787f1127 100644 --- a/src/simple-todos/step11/imports/ui/LoginForm.jsx +++ b/src/simple-todos/step11/imports/ui/LoginForm.jsx @@ -1,5 +1,6 @@ import { Meteor } from 'meteor/meteor'; import React, { useState } from 'react'; +import { LoginWithGithub } from './LoginWithGithub'; export const LoginForm = () => { const [username, setUsername] = useState(''); @@ -13,6 +14,7 @@ export const LoginForm = () => { return (
+
Date: Thu, 1 Sep 2022 15:35:35 -0300 Subject: [PATCH 28/60] chore(step11): updated taskForm.jsx --- src/simple-todos/step11/imports/ui/TaskForm.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/simple-todos/step11/imports/ui/TaskForm.jsx b/src/simple-todos/step11/imports/ui/TaskForm.jsx index 3d990238..4fe05a0c 100644 --- a/src/simple-todos/step11/imports/ui/TaskForm.jsx +++ b/src/simple-todos/step11/imports/ui/TaskForm.jsx @@ -4,7 +4,7 @@ import React, { useState } from 'react'; export const TaskForm = () => { const [text, setText] = useState(''); - const handleSubmit = e => { + const handleSubmit = async (e) => { e.preventDefault(); if (!text) return; From 329d7d9bd36cfdee3048d39920f3c55cff6507c6 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 15:47:20 -0300 Subject: [PATCH 29/60] fix(step11): updated missing async keywords --- src/simple-todos/step11/imports/ui/App.jsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/simple-todos/step11/imports/ui/App.jsx b/src/simple-todos/step11/imports/ui/App.jsx index 45eb54e9..709659ce 100644 --- a/src/simple-todos/step11/imports/ui/App.jsx +++ b/src/simple-todos/step11/imports/ui/App.jsx @@ -22,7 +22,7 @@ export const App = () => { const pendingOnlyFilter = { ...hideCompletedFilter, ...userFilter }; - const { tasks, pendingTasksCount, isLoading } = useTracker(() => { + const { tasks, pendingTasksCount, isLoading } = useTracker(async () => { const noDataAvailable = { tasks: [], pendingTasksCount: 0 }; if (!Meteor.user()) { return noDataAvailable; @@ -33,13 +33,14 @@ export const App = () => { return { ...noDataAvailable, isLoading: true }; } - const tasks = TasksCollection.find( + const tasks = await TasksCollection.find( hideCompleted ? pendingOnlyFilter : userFilter, { sort: { createdAt: -1 }, } - ).fetch(); - const pendingTasksCount = TasksCollection.find(pendingOnlyFilter).count(); + ).fetchAsync(); + const pendingTasksCount = await TasksCollection.find(pendingOnlyFilter) + .countAsync(); return { tasks, pendingTasksCount }; }); From 43b8302b1bbe696ec93a68e47dd6fc8e15c68cce Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 15:48:45 -0300 Subject: [PATCH 30/60] fix(step11): updated main.js --- src/simple-todos/step11/server/main.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/simple-todos/step11/server/main.js b/src/simple-todos/step11/server/main.js index 49a1e950..72cfd81f 100644 --- a/src/simple-todos/step11/server/main.js +++ b/src/simple-todos/step11/server/main.js @@ -5,8 +5,9 @@ import { ServiceConfiguration } from 'meteor/service-configuration'; import '/imports/api/tasksMethods'; import '/imports/api/tasksPublications'; -const insertTask = (taskText, user) => - TasksCollection.insert({ + +const insertTask = async (taskText, user) => + await TasksCollection.insertAsync({ text: taskText, userId: user._id, createdAt: new Date(), @@ -15,7 +16,7 @@ const insertTask = (taskText, user) => const SEED_USERNAME = 'meteorite'; const SEED_PASSWORD = 'password'; -Meteor.startup(() => { +Meteor.startup( async () => { if (!Accounts.findUserByUsername(SEED_USERNAME)) { Accounts.createUser({ username: SEED_USERNAME, @@ -24,8 +25,7 @@ Meteor.startup(() => { } const user = Accounts.findUserByUsername(SEED_USERNAME); - - if (TasksCollection.find().count() === 0) { + if (await TasksCollection.find().countAsync() === 0) { [ 'First Task', 'Second Task', @@ -37,7 +37,6 @@ Meteor.startup(() => { ].forEach(taskText => insertTask(taskText, user)); } }); - ServiceConfiguration.configurations.upsert( { service: 'github' }, { From 98b47b7bd6008b4ea90dd976d3e4a4642980b195 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 15:56:55 -0300 Subject: [PATCH 31/60] chore(step12): updated taskMethod.js --- .../step12/imports/api/tasksMethods.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/simple-todos/step12/imports/api/tasksMethods.js b/src/simple-todos/step12/imports/api/tasksMethods.js index 7b72b959..f4a93d82 100644 --- a/src/simple-todos/step12/imports/api/tasksMethods.js +++ b/src/simple-todos/step12/imports/api/tasksMethods.js @@ -3,37 +3,37 @@ import { check } from 'meteor/check'; import { TasksCollection } from '/imports/db/TasksCollection'; Meteor.methods({ - 'tasks.insert'(text) { + async 'tasks.insert'(text) { check(text, String); if (!this.userId) { throw new Meteor.Error('Not authorized.'); } - TasksCollection.insert({ + await TasksCollection.insertAsync({ text, createdAt: new Date(), userId: this.userId, }); }, - 'tasks.remove'(taskId) { + async 'tasks.remove'(taskId) { check(taskId, String); if (!this.userId) { throw new Meteor.Error('Not authorized.'); } - const task = TasksCollection.findOne({ _id: taskId, userId: this.userId }); + const task = await TasksCollection.findOneAsync({ _id: taskId, userId: this.userId }); if (!task) { throw new Meteor.Error('Access denied.'); } - TasksCollection.remove(taskId); + await TasksCollection.removeAsync(taskId); }, - 'tasks.setIsChecked'(taskId, isChecked) { + async 'tasks.setIsChecked'(taskId, isChecked) { check(taskId, String); check(isChecked, Boolean); @@ -41,13 +41,13 @@ Meteor.methods({ throw new Meteor.Error('Not authorized.'); } - const task = TasksCollection.findOne({ _id: taskId, userId: this.userId }); + const task = await TasksCollection.findOneAsync({ _id: taskId, userId: this.userId }); if (!task) { throw new Meteor.Error('Access denied.'); } - TasksCollection.update(taskId, { + await TasksCollection.updateAsync(taskId, { $set: { isChecked, }, From db0769a379e3ea97213b8dfa01f6fc1402f9fbc9 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 15:57:08 -0300 Subject: [PATCH 32/60] chore(step12): updated taskMethod.tests.js --- .../step12/imports/api/tasksMethods.tests.js | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/simple-todos/step12/imports/api/tasksMethods.tests.js b/src/simple-todos/step12/imports/api/tasksMethods.tests.js index f8a98336..c0fd56f8 100644 --- a/src/simple-todos/step12/imports/api/tasksMethods.tests.js +++ b/src/simple-todos/step12/imports/api/tasksMethods.tests.js @@ -7,57 +7,57 @@ import '/imports/api/tasksMethods'; if (Meteor.isServer) { describe('Tasks', () => { - describe('methods', () => { + describe('methods', async () => { const userId = Random.id(); let taskId; - beforeEach(() => { - TasksCollection.remove({}); - taskId = TasksCollection.insert({ + beforeEach(async () => { + await TasksCollection.removeAsync({}); + taskId = await TasksCollection.insertAsync({ text: 'Test Task', createdAt: new Date(), userId, }); }); - it('can delete owned task', () => { + it('can delete owned task', async () => { mockMethodCall('tasks.remove', taskId, { context: { userId } }); - assert.equal(TasksCollection.find().count(), 0); + assert.equal(await TasksCollection.find().countAsync(), 0); }); - it('can\'t delete task without an user authenticated', () => { + it('can\'t delete task without an user authenticated', async () => { const fn = () => mockMethodCall('tasks.remove', taskId); assert.throw(fn, /Not authorized/); - assert.equal(TasksCollection.find().count(), 1); + assert.equal(await TasksCollection.find().countAsync(), 1); }); - it('can\'t delete task from another owner', () => { + it('can\'t delete task from another owner', async () => { const fn = () => mockMethodCall('tasks.remove', taskId, { context: { userId: 'somebody-else-id' }, }); assert.throw(fn, /Access denied/); - assert.equal(TasksCollection.find().count(), 1); + assert.equal(await TasksCollection.find().countAsync(), 1); }); - it('can change the status of a task', () => { - const originalTask = TasksCollection.findOne(taskId); + it('can change the status of a task', async () => { + const originalTask = await TasksCollection.findOneAsync(taskId); mockMethodCall('tasks.setIsChecked', taskId, !originalTask.isChecked, { context: { userId }, }); - const updatedTask = TasksCollection.findOne(taskId); + const updatedTask = await TasksCollection.findOneAsync(taskId); assert.notEqual(updatedTask.isChecked, originalTask.isChecked); }); - it('can insert new tasks', () => { + it('can insert new tasks', async () => { const text = 'New Task'; mockMethodCall('tasks.insert', text, { context: { userId }, }); - const tasks = TasksCollection.find({}).fetch(); + const tasks = await TasksCollection.find({}).fetchAsync(); assert.equal(tasks.length, 2); assert.isTrue(tasks.some(task => task.text === text)); }); From 2e674536a96f395eff4a1c6abf710bc981d66250 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 15:57:17 -0300 Subject: [PATCH 33/60] chore(step12): updated app.jsx --- src/simple-todos/step12/imports/ui/App.jsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/simple-todos/step12/imports/ui/App.jsx b/src/simple-todos/step12/imports/ui/App.jsx index 45eb54e9..3aad04da 100644 --- a/src/simple-todos/step12/imports/ui/App.jsx +++ b/src/simple-todos/step12/imports/ui/App.jsx @@ -22,7 +22,7 @@ export const App = () => { const pendingOnlyFilter = { ...hideCompletedFilter, ...userFilter }; - const { tasks, pendingTasksCount, isLoading } = useTracker(() => { + const { tasks, pendingTasksCount, isLoading } = useTracker(async () => { const noDataAvailable = { tasks: [], pendingTasksCount: 0 }; if (!Meteor.user()) { return noDataAvailable; @@ -33,13 +33,13 @@ export const App = () => { return { ...noDataAvailable, isLoading: true }; } - const tasks = TasksCollection.find( + const tasks = await TasksCollection.find( hideCompleted ? pendingOnlyFilter : userFilter, { sort: { createdAt: -1 }, } - ).fetch(); - const pendingTasksCount = TasksCollection.find(pendingOnlyFilter).count(); + ).fetchAsync(); + const pendingTasksCount = await TasksCollection.find(pendingOnlyFilter).countAsync(); return { tasks, pendingTasksCount }; }); From d76c1931214e72b32d6eed8afbb64a093b1b3006 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 15:57:31 -0300 Subject: [PATCH 34/60] chore(step12): updated loginForm.jsx --- src/simple-todos/step12/imports/ui/LoginForm.jsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/simple-todos/step12/imports/ui/LoginForm.jsx b/src/simple-todos/step12/imports/ui/LoginForm.jsx index 3b814fc9..787f1127 100644 --- a/src/simple-todos/step12/imports/ui/LoginForm.jsx +++ b/src/simple-todos/step12/imports/ui/LoginForm.jsx @@ -1,5 +1,6 @@ import { Meteor } from 'meteor/meteor'; import React, { useState } from 'react'; +import { LoginWithGithub } from './LoginWithGithub'; export const LoginForm = () => { const [username, setUsername] = useState(''); @@ -13,6 +14,7 @@ export const LoginForm = () => { return ( +
Date: Thu, 1 Sep 2022 15:57:45 -0300 Subject: [PATCH 35/60] chore(step12): updated taskForm.jsx --- src/simple-todos/step12/imports/ui/TaskForm.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/simple-todos/step12/imports/ui/TaskForm.jsx b/src/simple-todos/step12/imports/ui/TaskForm.jsx index 3d990238..4fe05a0c 100644 --- a/src/simple-todos/step12/imports/ui/TaskForm.jsx +++ b/src/simple-todos/step12/imports/ui/TaskForm.jsx @@ -4,7 +4,7 @@ import React, { useState } from 'react'; export const TaskForm = () => { const [text, setText] = useState(''); - const handleSubmit = e => { + const handleSubmit = async (e) => { e.preventDefault(); if (!text) return; From fa548f7b262856a717eebaf43daeccab7447c6dc Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 15:58:06 -0300 Subject: [PATCH 36/60] chore(step13): updated taskForm.jsx --- src/simple-todos/step13/imports/ui/TaskForm.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/simple-todos/step13/imports/ui/TaskForm.jsx b/src/simple-todos/step13/imports/ui/TaskForm.jsx index 3d990238..4fe05a0c 100644 --- a/src/simple-todos/step13/imports/ui/TaskForm.jsx +++ b/src/simple-todos/step13/imports/ui/TaskForm.jsx @@ -4,7 +4,7 @@ import React, { useState } from 'react'; export const TaskForm = () => { const [text, setText] = useState(''); - const handleSubmit = e => { + const handleSubmit = async (e) => { e.preventDefault(); if (!text) return; From 39c7725bf67608019e6cc320e42260c2df25884d Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 15:58:18 -0300 Subject: [PATCH 37/60] chore(step13): updated LoginForm.jsx --- src/simple-todos/step13/imports/ui/LoginForm.jsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/simple-todos/step13/imports/ui/LoginForm.jsx b/src/simple-todos/step13/imports/ui/LoginForm.jsx index 3b814fc9..787f1127 100644 --- a/src/simple-todos/step13/imports/ui/LoginForm.jsx +++ b/src/simple-todos/step13/imports/ui/LoginForm.jsx @@ -1,5 +1,6 @@ import { Meteor } from 'meteor/meteor'; import React, { useState } from 'react'; +import { LoginWithGithub } from './LoginWithGithub'; export const LoginForm = () => { const [username, setUsername] = useState(''); @@ -13,6 +14,7 @@ export const LoginForm = () => { return ( +
Date: Thu, 1 Sep 2022 15:58:25 -0300 Subject: [PATCH 38/60] chore(step13): updated app.jsx --- src/simple-todos/step13/imports/ui/App.jsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/simple-todos/step13/imports/ui/App.jsx b/src/simple-todos/step13/imports/ui/App.jsx index 45eb54e9..3aad04da 100644 --- a/src/simple-todos/step13/imports/ui/App.jsx +++ b/src/simple-todos/step13/imports/ui/App.jsx @@ -22,7 +22,7 @@ export const App = () => { const pendingOnlyFilter = { ...hideCompletedFilter, ...userFilter }; - const { tasks, pendingTasksCount, isLoading } = useTracker(() => { + const { tasks, pendingTasksCount, isLoading } = useTracker(async () => { const noDataAvailable = { tasks: [], pendingTasksCount: 0 }; if (!Meteor.user()) { return noDataAvailable; @@ -33,13 +33,13 @@ export const App = () => { return { ...noDataAvailable, isLoading: true }; } - const tasks = TasksCollection.find( + const tasks = await TasksCollection.find( hideCompleted ? pendingOnlyFilter : userFilter, { sort: { createdAt: -1 }, } - ).fetch(); - const pendingTasksCount = TasksCollection.find(pendingOnlyFilter).count(); + ).fetchAsync(); + const pendingTasksCount = await TasksCollection.find(pendingOnlyFilter).countAsync(); return { tasks, pendingTasksCount }; }); From 708dab88b4db72a7260b66ffd364901de91b3f29 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 15:58:47 -0300 Subject: [PATCH 39/60] chore(step13): updated tasksMethods.tests.js --- .../step13/imports/api/tasksMethods.tests.js | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/simple-todos/step13/imports/api/tasksMethods.tests.js b/src/simple-todos/step13/imports/api/tasksMethods.tests.js index f8a98336..c0fd56f8 100644 --- a/src/simple-todos/step13/imports/api/tasksMethods.tests.js +++ b/src/simple-todos/step13/imports/api/tasksMethods.tests.js @@ -7,57 +7,57 @@ import '/imports/api/tasksMethods'; if (Meteor.isServer) { describe('Tasks', () => { - describe('methods', () => { + describe('methods', async () => { const userId = Random.id(); let taskId; - beforeEach(() => { - TasksCollection.remove({}); - taskId = TasksCollection.insert({ + beforeEach(async () => { + await TasksCollection.removeAsync({}); + taskId = await TasksCollection.insertAsync({ text: 'Test Task', createdAt: new Date(), userId, }); }); - it('can delete owned task', () => { + it('can delete owned task', async () => { mockMethodCall('tasks.remove', taskId, { context: { userId } }); - assert.equal(TasksCollection.find().count(), 0); + assert.equal(await TasksCollection.find().countAsync(), 0); }); - it('can\'t delete task without an user authenticated', () => { + it('can\'t delete task without an user authenticated', async () => { const fn = () => mockMethodCall('tasks.remove', taskId); assert.throw(fn, /Not authorized/); - assert.equal(TasksCollection.find().count(), 1); + assert.equal(await TasksCollection.find().countAsync(), 1); }); - it('can\'t delete task from another owner', () => { + it('can\'t delete task from another owner', async () => { const fn = () => mockMethodCall('tasks.remove', taskId, { context: { userId: 'somebody-else-id' }, }); assert.throw(fn, /Access denied/); - assert.equal(TasksCollection.find().count(), 1); + assert.equal(await TasksCollection.find().countAsync(), 1); }); - it('can change the status of a task', () => { - const originalTask = TasksCollection.findOne(taskId); + it('can change the status of a task', async () => { + const originalTask = await TasksCollection.findOneAsync(taskId); mockMethodCall('tasks.setIsChecked', taskId, !originalTask.isChecked, { context: { userId }, }); - const updatedTask = TasksCollection.findOne(taskId); + const updatedTask = await TasksCollection.findOneAsync(taskId); assert.notEqual(updatedTask.isChecked, originalTask.isChecked); }); - it('can insert new tasks', () => { + it('can insert new tasks', async () => { const text = 'New Task'; mockMethodCall('tasks.insert', text, { context: { userId }, }); - const tasks = TasksCollection.find({}).fetch(); + const tasks = await TasksCollection.find({}).fetchAsync(); assert.equal(tasks.length, 2); assert.isTrue(tasks.some(task => task.text === text)); }); From cfa23886faf350f78aad8d06db99d6944c44043f Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 15:58:51 -0300 Subject: [PATCH 40/60] chore(step13): updated tasksMethods.js --- .../step13/imports/api/tasksMethods.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/simple-todos/step13/imports/api/tasksMethods.js b/src/simple-todos/step13/imports/api/tasksMethods.js index 7b72b959..f4a93d82 100644 --- a/src/simple-todos/step13/imports/api/tasksMethods.js +++ b/src/simple-todos/step13/imports/api/tasksMethods.js @@ -3,37 +3,37 @@ import { check } from 'meteor/check'; import { TasksCollection } from '/imports/db/TasksCollection'; Meteor.methods({ - 'tasks.insert'(text) { + async 'tasks.insert'(text) { check(text, String); if (!this.userId) { throw new Meteor.Error('Not authorized.'); } - TasksCollection.insert({ + await TasksCollection.insertAsync({ text, createdAt: new Date(), userId: this.userId, }); }, - 'tasks.remove'(taskId) { + async 'tasks.remove'(taskId) { check(taskId, String); if (!this.userId) { throw new Meteor.Error('Not authorized.'); } - const task = TasksCollection.findOne({ _id: taskId, userId: this.userId }); + const task = await TasksCollection.findOneAsync({ _id: taskId, userId: this.userId }); if (!task) { throw new Meteor.Error('Access denied.'); } - TasksCollection.remove(taskId); + await TasksCollection.removeAsync(taskId); }, - 'tasks.setIsChecked'(taskId, isChecked) { + async 'tasks.setIsChecked'(taskId, isChecked) { check(taskId, String); check(isChecked, Boolean); @@ -41,13 +41,13 @@ Meteor.methods({ throw new Meteor.Error('Not authorized.'); } - const task = TasksCollection.findOne({ _id: taskId, userId: this.userId }); + const task = await TasksCollection.findOneAsync({ _id: taskId, userId: this.userId }); if (!task) { throw new Meteor.Error('Access denied.'); } - TasksCollection.update(taskId, { + await TasksCollection.updateAsync(taskId, { $set: { isChecked, }, From 0ee4a4243332b7874a92860eefd092e65bf603aa Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 16:36:21 -0300 Subject: [PATCH 41/60] fix(step02): added missing async await --- src/simple-todos/step02/imports/ui/App.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/simple-todos/step02/imports/ui/App.jsx b/src/simple-todos/step02/imports/ui/App.jsx index 19d0ea36..1edfac8e 100644 --- a/src/simple-todos/step02/imports/ui/App.jsx +++ b/src/simple-todos/step02/imports/ui/App.jsx @@ -4,7 +4,7 @@ import { TasksCollection } from '/imports/api/TasksCollection'; import { Task } from './Task'; export const App = () => { - const tasks = useTracker(() => TasksCollection.find({}).fetch()); + const tasks = useTracker(async () => await TasksCollection.find({}).fetchAsync()); return (
From c5bae2317066794ad2327b78b637f13eae9e4249 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 17:05:37 -0300 Subject: [PATCH 42/60] fix(step02): added async to main.js --- src/simple-todos/step02/server/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/simple-todos/step02/server/main.js b/src/simple-todos/step02/server/main.js index ed90033b..75959502 100644 --- a/src/simple-todos/step02/server/main.js +++ b/src/simple-todos/step02/server/main.js @@ -2,7 +2,7 @@ import { Meteor } from 'meteor/meteor'; import { TasksCollection } from '/imports/api/TasksCollection'; const insertTask = - async (taskText) => TasksCollection.insertAsync({ text: taskText }); + async (taskText) => await TasksCollection.insertAsync({ text: taskText }); Meteor.startup(async () => { if (await TasksCollection.find().countAsync() === 0) { From e2ae6cbd6c3798f9b50f935fa03f42632283e81c Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 17:05:55 -0300 Subject: [PATCH 43/60] fix(step04): added async to app.jsx --- src/simple-todos/step04/imports/ui/App.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/simple-todos/step04/imports/ui/App.jsx b/src/simple-todos/step04/imports/ui/App.jsx index 4b3fa641..3098bea1 100644 --- a/src/simple-todos/step04/imports/ui/App.jsx +++ b/src/simple-todos/step04/imports/ui/App.jsx @@ -14,7 +14,7 @@ const toggleChecked = }; const deleteTask = - async ({ _id }) => TasksCollection.removeAsync(_id); + async ({ _id }) => await TasksCollection.removeAsync(_id); export const App = () => { const tasks = useTracker(async () => From 8f8235b7dd38a05be0c74fea7138ff8db65ba0d9 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 17:06:06 -0300 Subject: [PATCH 44/60] fix(step05): added async to app.jsx --- src/simple-todos/step05/imports/ui/App.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/simple-todos/step05/imports/ui/App.jsx b/src/simple-todos/step05/imports/ui/App.jsx index ea12d8b0..a7f6fb54 100644 --- a/src/simple-todos/step05/imports/ui/App.jsx +++ b/src/simple-todos/step05/imports/ui/App.jsx @@ -14,7 +14,7 @@ const toggleChecked = }; const deleteTask = - async ({ _id }) => TasksCollection.removeAsync(_id); + async ({ _id }) => await TasksCollection.removeAsync(_id); export const App = () => { const tasks = useTracker(async () => From 2ff49c0876d886c320bd23d1ab562473332b9492 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 17:06:15 -0300 Subject: [PATCH 45/60] fix(step06): added async to app.jsx --- src/simple-todos/step06/imports/ui/App.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/simple-todos/step06/imports/ui/App.jsx b/src/simple-todos/step06/imports/ui/App.jsx index 51e9b86c..f929df54 100644 --- a/src/simple-todos/step06/imports/ui/App.jsx +++ b/src/simple-todos/step06/imports/ui/App.jsx @@ -14,7 +14,7 @@ const toggleChecked = }; const deleteTask = - async ({ _id }) => TasksCollection.removeAsync(_id); + async ({ _id }) => await TasksCollection.removeAsync(_id); export const App = () => { const [hideCompleted, setHideCompleted] = useState(false); From def3f0d9ab4268ed9cc3aa393130b514bf69095a Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 17:06:21 -0300 Subject: [PATCH 46/60] fix(step07): added async to app.jsx --- src/simple-todos/step07/imports/ui/App.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/simple-todos/step07/imports/ui/App.jsx b/src/simple-todos/step07/imports/ui/App.jsx index 69130256..85916279 100644 --- a/src/simple-todos/step07/imports/ui/App.jsx +++ b/src/simple-todos/step07/imports/ui/App.jsx @@ -16,7 +16,7 @@ const toggleChecked = }; const deleteTask = - async ({ _id }) => TasksCollection.removeAsync(_id); + async ({ _id }) => await TasksCollection.removeAsync(_id); export const App = () => { const user = useTracker(() => Meteor.user()); @@ -34,7 +34,7 @@ export const App = () => { return []; } - return TasksCollection.find( + return await TasksCollection.find( hideCompleted ? pendingOnlyFilter : userFilter, { sort: { createdAt: -1 }, @@ -47,7 +47,7 @@ export const App = () => { return 0; } - return TasksCollection.find(pendingOnlyFilter).countAsync(); + return await TasksCollection.find(pendingOnlyFilter).countAsync(); }); const pendingTasksTitle = `${ From c8340eac068ee2b84211992a3646f032dacc0139 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 17:06:27 -0300 Subject: [PATCH 47/60] fix(step08): added async to app.jsx --- src/simple-todos/step08/imports/ui/App.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/simple-todos/step08/imports/ui/App.jsx b/src/simple-todos/step08/imports/ui/App.jsx index c4278465..cf7c4261 100644 --- a/src/simple-todos/step08/imports/ui/App.jsx +++ b/src/simple-todos/step08/imports/ui/App.jsx @@ -16,7 +16,7 @@ const toggleChecked = }; const deleteTask = - async ({ _id }) => TasksCollection.removeAsync(_id); + async ({ _id }) => await TasksCollection.removeAsync(_id); export const App = () => { const user = useTracker(() => Meteor.user()); From b17e31d96e93f37cfaf5a336b93354b6ca0cdcda Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 17:06:53 -0300 Subject: [PATCH 48/60] fix(step03): converted to async in TaskForm.jsx --- src/simple-todos/step03/imports/ui/TaskForm.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/simple-todos/step03/imports/ui/TaskForm.jsx b/src/simple-todos/step03/imports/ui/TaskForm.jsx index cf4a4e30..414056a5 100644 --- a/src/simple-todos/step03/imports/ui/TaskForm.jsx +++ b/src/simple-todos/step03/imports/ui/TaskForm.jsx @@ -4,12 +4,12 @@ import { TasksCollection } from '/imports/api/TasksCollection'; export const TaskForm = () => { const [text, setText] = useState(''); - const handleSubmit = e => { + const handleSubmit = async (e) => { e.preventDefault(); if (!text) return; - TasksCollection.insert({ + await TasksCollection.insertAsync({ text: text.trim(), createdAt: new Date(), }); From 3721394a6f1b55a59c57abb1aef3cea4802403e4 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 17:07:00 -0300 Subject: [PATCH 49/60] fix(step04): converted to async in TaskForm.jsx --- src/simple-todos/step04/imports/ui/TaskForm.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/simple-todos/step04/imports/ui/TaskForm.jsx b/src/simple-todos/step04/imports/ui/TaskForm.jsx index cf4a4e30..414056a5 100644 --- a/src/simple-todos/step04/imports/ui/TaskForm.jsx +++ b/src/simple-todos/step04/imports/ui/TaskForm.jsx @@ -4,12 +4,12 @@ import { TasksCollection } from '/imports/api/TasksCollection'; export const TaskForm = () => { const [text, setText] = useState(''); - const handleSubmit = e => { + const handleSubmit = async (e) => { e.preventDefault(); if (!text) return; - TasksCollection.insert({ + await TasksCollection.insertAsync({ text: text.trim(), createdAt: new Date(), }); From a5b1e2272580af699290d6687fe3e360ebb92149 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 17:07:07 -0300 Subject: [PATCH 50/60] fix(step05): converted to async in TaskForm.jsx --- src/simple-todos/step05/imports/ui/TaskForm.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/simple-todos/step05/imports/ui/TaskForm.jsx b/src/simple-todos/step05/imports/ui/TaskForm.jsx index cf4a4e30..414056a5 100644 --- a/src/simple-todos/step05/imports/ui/TaskForm.jsx +++ b/src/simple-todos/step05/imports/ui/TaskForm.jsx @@ -4,12 +4,12 @@ import { TasksCollection } from '/imports/api/TasksCollection'; export const TaskForm = () => { const [text, setText] = useState(''); - const handleSubmit = e => { + const handleSubmit = async (e) => { e.preventDefault(); if (!text) return; - TasksCollection.insert({ + await TasksCollection.insertAsync({ text: text.trim(), createdAt: new Date(), }); From aedb561bb878580a45384b55ae46765cdcf12f46 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 17:07:15 -0300 Subject: [PATCH 51/60] fix(step06): converted to async in TaskForm.jsx --- src/simple-todos/step06/imports/ui/TaskForm.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/simple-todos/step06/imports/ui/TaskForm.jsx b/src/simple-todos/step06/imports/ui/TaskForm.jsx index cf4a4e30..414056a5 100644 --- a/src/simple-todos/step06/imports/ui/TaskForm.jsx +++ b/src/simple-todos/step06/imports/ui/TaskForm.jsx @@ -4,12 +4,12 @@ import { TasksCollection } from '/imports/api/TasksCollection'; export const TaskForm = () => { const [text, setText] = useState(''); - const handleSubmit = e => { + const handleSubmit = async (e) => { e.preventDefault(); if (!text) return; - TasksCollection.insert({ + await TasksCollection.insertAsync({ text: text.trim(), createdAt: new Date(), }); From 4261c9dbff0c4d308b99b52c74eaf4ad6766f82d Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 17:14:24 -0300 Subject: [PATCH 52/60] docs(step02): updated docs to mongo api --- tutorial/simple-todos/02-collections.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tutorial/simple-todos/02-collections.md b/tutorial/simple-todos/02-collections.md index 45b97d44..a06dc3dc 100644 --- a/tutorial/simple-todos/02-collections.md +++ b/tutorial/simple-todos/02-collections.md @@ -40,10 +40,11 @@ You don't need to keep the old content of `server/main.js`. import { Meteor } from 'meteor/meteor'; import { TasksCollection } from '/imports/api/TasksCollection'; -const insertTask = taskText => TasksCollection.insert({ text: taskText }); +const insertTask = + async (taskText) => await TasksCollection.insertAsync({ text: taskText }); -Meteor.startup(() => { - if (TasksCollection.find().count() === 0) { +Meteor.startup(async () => { + if (await TasksCollection.find().countAsync() === 0) { [ 'First Task', 'Second Task', @@ -85,7 +86,7 @@ import { TasksCollection } from '/imports/api/TasksCollection'; import { Task } from './Task'; export const App = () => { - const tasks = useTracker(() => TasksCollection.find({}).fetch()); + const tasks = useTracker(async () => await TasksCollection.find({}).fetchAsync()); return (
From b7199306519fef35c686f44124610f78c6fc32d5 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 17:45:56 -0300 Subject: [PATCH 53/60] fix(step07): missing params in main.js --- src/simple-todos/step07/server/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/simple-todos/step07/server/main.js b/src/simple-todos/step07/server/main.js index b6025985..a99b1d4e 100644 --- a/src/simple-todos/step07/server/main.js +++ b/src/simple-todos/step07/server/main.js @@ -30,6 +30,6 @@ Meteor.startup( async () => { 'Fifth Task', 'Sixth Task', 'Seventh Task', - ].forEach(insertTask); + ].forEach(taskText => insertTask(taskText, user)); } }); From d6277736f303201f99b20b41b3f3438845cf15ea Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 17:46:15 -0300 Subject: [PATCH 54/60] docs(step03): updated docs to async mongo api --- tutorial/simple-todos/03-forms-and-events.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tutorial/simple-todos/03-forms-and-events.md b/tutorial/simple-todos/03-forms-and-events.md index 77caed4a..43388631 100644 --- a/tutorial/simple-todos/03-forms-and-events.md +++ b/tutorial/simple-todos/03-forms-and-events.md @@ -47,7 +47,7 @@ import { TasksCollection } from '/imports/api/TasksCollection'; import { TaskForm } from './TaskForm'; export const App = () => { - const tasks = useTracker(() => TasksCollection.find({}).fetch()); + const tasks = useTracker(async () => await TasksCollection.find({}).fetchAsync()); return (
@@ -90,17 +90,17 @@ import { TasksCollection } from '/imports/api/TasksCollection'; export const TaskForm = () => { const [text, setText] = useState(""); - const handleSubmit = e => { + const handleSubmit = async (e) => { e.preventDefault(); if (!text) return; - TasksCollection.insert({ + await TasksCollection.insertAsync({ text: text.trim(), - createdAt: new Date() + createdAt: new Date(), }); - setText(""); + setText(''); }; return ( @@ -129,7 +129,9 @@ Now you just need to make a change that will make users happy: we need to show t .. export const App = () => { - const tasks = useTracker(() => TasksCollection.find({}, { sort: { createdAt: -1 } }).fetch()); + const tasks = useTracker(async () => + await TasksCollection.find({}, { sort: { createdAt: -1 } }).fetchAsync() + ); .. ``` From 8b2ad9e7cb4a20b7e1b2eb9a2cd137fd03dba44c Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 17:46:27 -0300 Subject: [PATCH 55/60] docs(step04): updated docs to async mongo api --- tutorial/simple-todos/04-update-and-remove.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tutorial/simple-todos/04-update-and-remove.md b/tutorial/simple-todos/04-update-and-remove.md index 3bae2f07..ab45a48b 100644 --- a/tutorial/simple-todos/04-update-and-remove.md +++ b/tutorial/simple-todos/04-update-and-remove.md @@ -45,13 +45,14 @@ Create a function to change your document and pass it along to your `Task` compo `imports/ui/App.jsx` ```js -const toggleChecked = ({ _id, isChecked }) => { - TasksCollection.update(_id, { - $set: { - isChecked: !isChecked - } - }) -}; +const toggleChecked = + async ({ _id, isChecked }) => { + await TasksCollection.updateAsync(_id, { + $set: { + isChecked: !isChecked, + }, + }); + }; export const App = () => { .. @@ -89,7 +90,8 @@ Now add the removal logic in the `App`, you need to have a function to delete th `imports/ui/App.jsx` ```js -const deleteTask = ({ _id }) => TasksCollection.remove(_id); +const deleteTask = + async ({ _id }) => await TasksCollection.removeAsync(_id); export const App = () => { .. From 5e07dee687ba32faa285f523cface8c6dd1bf90e Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 17:46:45 -0300 Subject: [PATCH 56/60] docs(step06): updated docs to async mongo api --- tutorial/simple-todos/06-filter-tasks.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tutorial/simple-todos/06-filter-tasks.md b/tutorial/simple-todos/06-filter-tasks.md index 3d9d5de8..46b5f81f 100644 --- a/tutorial/simple-todos/06-filter-tasks.md +++ b/tutorial/simple-todos/06-filter-tasks.md @@ -62,10 +62,10 @@ Now, if the user wants to see only pending tasks you can add a filter to your se .. const hideCompletedFilter = { isChecked: { $ne: true } }; - const tasks = useTracker(() => - TasksCollection.find(hideCompleted ? hideCompletedFilter : {}, { + const tasks = useTracker(async () => + await TasksCollection.find(hideCompleted ? hideCompletedFilter : {}, { sort: { createdAt: -1 }, - }).fetch() + }).fetchAsync() ); .. ``` @@ -93,8 +93,8 @@ You should avoid adding zero to your app bar when there are no pending tasks. `imports/ui/App.jsx` ```js .. - const pendingTasksCount = useTracker(() => - TasksCollection.find(hideCompletedFilter).count() + const pendingTasksCount = useTracker(async () => + await TasksCollection.find(hideCompletedFilter).countAsync() ); const pendingTasksTitle = `${ From a59128e72bb288d8720eb054b87e29d701f455ae Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 17:46:59 -0300 Subject: [PATCH 57/60] docs(step07): updated docs to async mongo api --- .../simple-todos/07-adding-user-accounts.md | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tutorial/simple-todos/07-adding-user-accounts.md b/tutorial/simple-todos/07-adding-user-accounts.md index 584cfc8c..d0be016e 100644 --- a/tutorial/simple-todos/07-adding-user-accounts.md +++ b/tutorial/simple-todos/07-adding-user-accounts.md @@ -263,8 +263,8 @@ import { Meteor } from 'meteor/meteor'; import { Accounts } from 'meteor/accounts-base'; import { TasksCollection } from '/imports/api/TasksCollection'; -const insertTask = (taskText, user) => - TasksCollection.insert({ +const insertTask = async (taskText, user) => + await TasksCollection.insertAsync({ text: taskText, userId: user._id, createdAt: new Date(), @@ -273,7 +273,7 @@ const insertTask = (taskText, user) => const SEED_USERNAME = 'meteorite'; const SEED_PASSWORD = 'password'; -Meteor.startup(() => { +Meteor.startup( async () => { if (!Accounts.findUserByUsername(SEED_USERNAME)) { Accounts.createUser({ username: SEED_USERNAME, @@ -283,7 +283,7 @@ Meteor.startup(() => { const user = Accounts.findUserByUsername(SEED_USERNAME); - if (TasksCollection.find().count() === 0) { + if (await TasksCollection.find().countAsync() === 0) { [ 'First Task', 'Second Task', @@ -313,25 +313,25 @@ Now you can filter the tasks in the UI by the authenticated user. Use the user ` const pendingOnlyFilter = { ...hideCompletedFilter, ...userFilter }; - const tasks = useTracker(() => { + const tasks = useTracker(async () => { if (!user) { return []; } - - return TasksCollection.find( + + return await TasksCollection.find( hideCompleted ? pendingOnlyFilter : userFilter, { sort: { createdAt: -1 }, } - ).fetch(); + ).fetchAsync(); }); - - const pendingTasksCount = useTracker(() => { + + const pendingTasksCount = useTracker(async () => { if (!user) { return 0; } - - return TasksCollection.find(pendingOnlyFilter).count(); + + return await TasksCollection.find(pendingOnlyFilter).countAsync(); }); .. @@ -347,12 +347,12 @@ Also, update the `insert` call to include the field `userId` in the `TaskForm`. export const TaskForm = ({ user }) => { const [text, setText] = useState(''); - const handleSubmit = e => { + const handleSubmit = async (e) => { e.preventDefault(); if (!text) return; - TasksCollection.insert({ + await TasksCollection.insertAsync({ text: text.trim(), createdAt: new Date(), userId: user._id From 6cd15f7944dad86331d06923b69332566495044c Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 17:47:16 -0300 Subject: [PATCH 58/60] docs(step09): updated docs to async mongo api --- tutorial/simple-todos/09-methods.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tutorial/simple-todos/09-methods.md b/tutorial/simple-todos/09-methods.md index fd77d4b4..f9bae095 100644 --- a/tutorial/simple-todos/09-methods.md +++ b/tutorial/simple-todos/09-methods.md @@ -58,44 +58,44 @@ import { check } from 'meteor/check'; import { TasksCollection } from './TasksCollection'; Meteor.methods({ - 'tasks.insert'(text) { + async 'tasks.insert'(text) { check(text, String); if (!this.userId) { throw new Meteor.Error('Not authorized.'); } - TasksCollection.insert({ + await TasksCollection.insertAsync({ text, - createdAt: new Date, + createdAt: new Date(), userId: this.userId, - }) + }); }, - 'tasks.remove'(taskId) { + async 'tasks.remove'(taskId) { check(taskId, String); if (!this.userId) { throw new Meteor.Error('Not authorized.'); } - TasksCollection.remove(taskId); + await TasksCollection.removeAsync(taskId); }, - 'tasks.setIsChecked'(taskId, isChecked) { + async 'tasks.setIsChecked'(taskId, isChecked) { check(taskId, String); check(isChecked, Boolean); - + if (!this.userId) { throw new Meteor.Error('Not authorized.'); } - TasksCollection.update(taskId, { + await TasksCollection.updateAsync(taskId, { $set: { - isChecked - } + isChecked, + }, }); - } + }, }); ``` @@ -128,7 +128,7 @@ import React, { useState } from 'react'; export const TaskForm = () => { const [text, setText] = useState(''); - const handleSubmit = e => { + const handleSubmit = async (e) => { e.preventDefault(); if (!text) return; From 2f608a9c6918fb1dbba5d62a066f398b7c58a063 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 17:47:37 -0300 Subject: [PATCH 59/60] docs(step10): updated docs to async mongo api --- tutorial/simple-todos/10-publications.md | 113 ++++++++++++----------- 1 file changed, 57 insertions(+), 56 deletions(-) diff --git a/tutorial/simple-todos/10-publications.md b/tutorial/simple-todos/10-publications.md index 5e0b75f3..9360d31c 100644 --- a/tutorial/simple-todos/10-publications.md +++ b/tutorial/simple-todos/10-publications.md @@ -60,27 +60,28 @@ It's also a good moment for us to refactor our code to use a single `useTracker` ```js .. - const { tasks, pendingTasksCount, isLoading } = useTracker(() => { - const noDataAvailable = { tasks: [], pendingTasksCount: 0 }; - if (!Meteor.user()) { - return noDataAvailable; - } - const handler = Meteor.subscribe('tasks'); - - if (!handler.ready()) { - return { ...noDataAvailable, isLoading: true }; - } - - const tasks = TasksCollection.find( - hideCompleted ? pendingOnlyFilter : userFilter, - { - sort: { createdAt: -1 }, + const { tasks, pendingTasksCount, isLoading } = useTracker(async () => { + const noDataAvailable = { tasks: [], pendingTasksCount: 0 }; + if (!Meteor.user()) { + return noDataAvailable; } - ).fetch(); - const pendingTasksCount = TasksCollection.find(pendingOnlyFilter).count(); - - return { tasks, pendingTasksCount }; - }); + const handler = Meteor.subscribe('tasks'); + + if (!handler.ready()) { + return { ...noDataAvailable, isLoading: true }; + } + + const tasks = await TasksCollection.find( + hideCompleted ? pendingOnlyFilter : userFilter, + { + sort: { createdAt: -1 }, + } + ).fetchAsync(); + const pendingTasksCount = await TasksCollection.find(pendingOnlyFilter) + .countAsync(); + + return { tasks, pendingTasksCount }; + }); .. ``` @@ -133,42 +134,42 @@ Only the owner of a task should be able to change certain things. You should cha ```js .. - 'tasks.remove'(taskId) { - check(taskId, String); - - if (!this.userId) { - throw new Meteor.Error('Not authorized.'); - } - - const task = TasksCollection.findOne({ _id: taskId, userId: this.userId }); - - if (!task) { - throw new Meteor.Error('Access denied.'); - } - - TasksCollection.remove(taskId); - }, - - 'tasks.setIsChecked'(taskId, isChecked) { - check(taskId, String); - check(isChecked, Boolean); - - if (!this.userId) { - throw new Meteor.Error('Not authorized.'); - } - - const task = TasksCollection.findOne({ _id: taskId, userId: this.userId }); - - if (!task) { - throw new Meteor.Error('Access denied.'); - } - - TasksCollection.update(taskId, { - $set: { - isChecked, - }, - }); - }, + async 'tasks.remove'(taskId) { + check(taskId, String); + + if (!this.userId) { + throw new Meteor.Error('Not authorized.'); + } + + const task = await TasksCollection.findOneAsync({ _id: taskId, userId: this.userId }); + + if (!task) { + throw new Meteor.Error('Access denied.'); + } + + await TasksCollection.removeAsync(taskId); + }, + + async 'tasks.setIsChecked'(taskId, isChecked) { + check(taskId, String); + check(isChecked, Boolean); + + if (!this.userId) { + throw new Meteor.Error('Not authorized.'); + } + + const task = await TasksCollection.findOneAsync({ _id: taskId, userId: this.userId }); + + if (!task) { + throw new Meteor.Error('Access denied.'); + } + + await TasksCollection.updateAsync(taskId, { + $set: { + isChecked, + }, + }); + }, .. ``` From 2bb7f9f11724bb627f0bdc8d4134731f438e5b74 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Thu, 1 Sep 2022 17:47:48 -0300 Subject: [PATCH 60/60] docs(step12): updated docs to async mongo api --- tutorial/simple-todos/12-testing.md | 44 ++++++++++++++--------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/tutorial/simple-todos/12-testing.md b/tutorial/simple-todos/12-testing.md index c9d606f9..f2ac3bc1 100644 --- a/tutorial/simple-todos/12-testing.md +++ b/tutorial/simple-todos/12-testing.md @@ -82,9 +82,9 @@ if (Meteor.isServer) { const userId = Random.id(); let taskId; - beforeEach(() => { - TasksCollection.remove({}); - taskId = TasksCollection.insert({ + beforeEach(async () => { + await TasksCollection.removeAsync({}); + taskId = await TasksCollection.insertAsync({ text: 'Test Task', createdAt: new Date(), userId, @@ -121,19 +121,19 @@ if (Meteor.isServer) { const userId = Random.id(); let taskId; - beforeEach(() => { - TasksCollection.remove({}); - taskId = TasksCollection.insert({ + beforeEach(async () => { + await TasksCollection.removeAsync({}); + taskId = await TasksCollection.insertAsync({ text: 'Test Task', createdAt: new Date(), userId, }); }); - it('can delete owned task', () => { + it('can delete owned task', async () => { mockMethodCall('tasks.remove', taskId, { context: { userId } }); - assert.equal(TasksCollection.find().count(), 0); + assert.equal(await TasksCollection.find().countAsync(), 0); }); }); }); @@ -162,53 +162,53 @@ if (Meteor.isServer) { const userId = Random.id(); let taskId; - beforeEach(() => { - TasksCollection.remove({}); - taskId = TasksCollection.insert({ + beforeEach(async () => { + await TasksCollection.removeAsync({}); + taskId = await TasksCollection.insertAsync({ text: 'Test Task', createdAt: new Date(), userId, }); }); - it('can delete owned task', () => { + it('can delete owned task', async () => { mockMethodCall('tasks.remove', taskId, { context: { userId } }); - assert.equal(TasksCollection.find().count(), 0); + assert.equal(await TasksCollection.find().countAsync(), 0); }); - it(`can't delete task without an user authenticated`, () => { + it('can\'t delete task without an user authenticated', async () => { const fn = () => mockMethodCall('tasks.remove', taskId); assert.throw(fn, /Not authorized/); - assert.equal(TasksCollection.find().count(), 1); + assert.equal(await TasksCollection.find().countAsync(), 1); }); - it(`can't delete task from another owner`, () => { + it('can\'t delete task from another owner', async () => { const fn = () => mockMethodCall('tasks.remove', taskId, { context: { userId: 'somebody-else-id' }, }); assert.throw(fn, /Access denied/); - assert.equal(TasksCollection.find().count(), 1); + assert.equal(await TasksCollection.find().countAsync(), 1); }); - it('can change the status of a task', () => { - const originalTask = TasksCollection.findOne(taskId); + it('can change the status of a task', async () => { + const originalTask = await TasksCollection.findOneAsync(taskId); mockMethodCall('tasks.setIsChecked', taskId, !originalTask.isChecked, { context: { userId }, }); - const updatedTask = TasksCollection.findOne(taskId); + const updatedTask = await TasksCollection.findOneAsync(taskId); assert.notEqual(updatedTask.isChecked, originalTask.isChecked); }); - it('can insert new tasks', () => { + it('can insert new tasks', async () => { const text = 'New Task'; mockMethodCall('tasks.insert', text, { context: { userId }, }); - const tasks = TasksCollection.find({}).fetch(); + const tasks = await TasksCollection.find({}).fetchAsync(); assert.equal(tasks.length, 2); assert.isTrue(tasks.some(task => task.text === text)); });