Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
1dbc376
chore(step02): added mongo async API
Grubba27 Sep 5, 2022
01cc2b6
chore(step03): added mongo async API
Grubba27 Sep 5, 2022
01f8460
chore(step03): added mongo async API in main.js
Grubba27 Sep 5, 2022
0ba6aa8
chore(step04): added mongo async API in App.js
Grubba27 Sep 5, 2022
f40bea5
chore(step04): added mongo async API in Task.js
Grubba27 Sep 5, 2022
73c81ae
chore(step04): added mongo async API in main.js
Grubba27 Sep 5, 2022
637eb8b
chore(step05): added mongo async API in App.js
Grubba27 Sep 5, 2022
66616b8
chore(step05): added mongo async API in Task.js
Grubba27 Sep 5, 2022
4fdbcd0
chore(step05): added mongo async API in server.js
Grubba27 Sep 5, 2022
20ea905
chore(step06): added mongo async API in App.js
Grubba27 Sep 5, 2022
1fa20b6
chore(step06): added mongo async API in Task.js
Grubba27 Sep 5, 2022
96d1637
chore(step06): added mongo async API in main.js
Grubba27 Sep 5, 2022
1ccfcc0
chore(step07): added mongo async API in App.js
Grubba27 Sep 5, 2022
5011e0b
chore(step07): added mongo async API in Task.js
Grubba27 Sep 5, 2022
f7d2943
chore(step07): added mongo async API in main.js
Grubba27 Sep 5, 2022
ee5df0c
chore(step08): added mongo async API in taskMethods.js
Grubba27 Sep 5, 2022
bf3c320
chore(step08): added mongo async API in app.js
Grubba27 Sep 5, 2022
47e84c2
chore(step08): added mongo async API in Main.js
Grubba27 Sep 5, 2022
53f696e
chore(step09): added mongo async API in taskMethiods.js
Grubba27 Sep 5, 2022
8687992
chore(step09): added mongo async API in App.js
Grubba27 Sep 5, 2022
b9346ea
chore(step09): added mongo async API in main.js
Grubba27 Sep 5, 2022
1bb2e3b
chore(step10): added mongo async API in taskMethods.js
Grubba27 Sep 5, 2022
f356dbe
chore(step10): added mongo async API in App.js
Grubba27 Sep 5, 2022
58b0569
chore(step10): added mongo async API in main.js
Grubba27 Sep 5, 2022
fa8a37a
chore(step11): added mongo async API in step 11
Grubba27 Sep 5, 2022
fa26dd9
chore(step12): added mongo async API in step 12
Grubba27 Sep 5, 2022
708cfcf
chore(step13): added mongo async API in step 13
Grubba27 Sep 5, 2022
5f7901b
docs: updated step 2 with new Mongo async API
Grubba27 Sep 5, 2022
c334fb6
docs: updated step 3 with new Mongo async API
Grubba27 Sep 5, 2022
59c4e6f
docs: updated step 4 with new Mongo async API
Grubba27 Sep 5, 2022
8db739c
docs: updated step 6 with new Mongo async API
Grubba27 Sep 5, 2022
0380903
docs: updated step 7 with new Mongo async API
Grubba27 Sep 5, 2022
091e428
docs: updated step 8 with new Mongo async API
Grubba27 Sep 5, 2022
df88896
docs: updated step 9 with new Mongo async API
Grubba27 Sep 5, 2022
67898f1
docs: updated step 11 with new Mongo async API
Grubba27 Sep 5, 2022
7f4911e
chore: update changelog with mongo async api
Grubba27 Sep 5, 2022
990fa0e
chore: added missing await token for main.js
Grubba27 Sep 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/simple-todos/step02/server/main.js
Original file line number Diff line number Diff line change
@@ -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) =>
await TasksCollection.insertAsync({ text: taskText });

Meteor.startup(() => {
if (TasksCollection.find().count() === 0) {
Meteor.startup(async () => {
if (TasksCollection.find().countAsync() === 0) {
[
'First Task',
'Second Task',
Expand Down
4 changes: 2 additions & 2 deletions src/simple-todos/step03/imports/ui/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Template.mainContainer.helpers({
});

Template.form.events({
'submit .task-form'(event) {
async 'submit .task-form'(event) {
// Prevent default browser form submit
event.preventDefault();

Expand All @@ -18,7 +18,7 @@ Template.form.events({
const text = target.text.value;

// Insert a task into the collection
TasksCollection.insert({
await TasksCollection.insertAsync({
text,
createdAt: new Date(), // current time
});
Expand Down
7 changes: 4 additions & 3 deletions src/simple-todos/step03/server/main.js
Original file line number Diff line number Diff line change
@@ -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) =>
await TasksCollection.insertAsync({ text: taskText });

Meteor.startup(() => {
if (TasksCollection.find().count() === 0) {
Meteor.startup(async () => {
if (TasksCollection.find().countAsync() === 0) {
[
'First Task',
'Second Task',
Expand Down
4 changes: 2 additions & 2 deletions src/simple-todos/step04/imports/ui/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Template.mainContainer.helpers({
});

Template.form.events({
'submit .task-form'(event) {
async 'submit .task-form'(event) {
// Prevent default browser form submit
event.preventDefault();

Expand All @@ -19,7 +19,7 @@ Template.form.events({
const text = target.text.value;

// Insert a task into the collection
TasksCollection.insert({
await TasksCollection.insertAsync({
text,
createdAt: new Date(), // current time
});
Expand Down
8 changes: 4 additions & 4 deletions src/simple-todos/step04/imports/ui/Task.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { TasksCollection } from '../api/TasksCollection';
import './Task.html';

Template.task.events({
'click .toggle-checked'() {
async 'click .toggle-checked'() {
// Set the checked property to the opposite of its current value
TasksCollection.update(this._id, {
await TasksCollection.updateAsync(this._id, {
$set: { isChecked: !this.isChecked },
});
},
'click .delete'() {
TasksCollection.remove(this._id);
async 'click .delete'() {
await TasksCollection.removeAsync(this._id);
},
});
7 changes: 4 additions & 3 deletions src/simple-todos/step04/server/main.js
Original file line number Diff line number Diff line change
@@ -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) =>
await TasksCollection.insertAsync({ text: taskText });

Meteor.startup(() => {
if (TasksCollection.find().count() === 0) {
Meteor.startup(async () => {
if (TasksCollection.find().countAsync() === 0) {
[
'First Task',
'Second Task',
Expand Down
4 changes: 2 additions & 2 deletions src/simple-todos/step05/imports/ui/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Template.mainContainer.helpers({
});

Template.form.events({
'submit .task-form'(event) {
async 'submit .task-form'(event) {
// Prevent default browser form submit
event.preventDefault();

Expand All @@ -19,7 +19,7 @@ Template.form.events({
const text = target.text.value;

// Insert a task into the collection
TasksCollection.insert({
await TasksCollection.insertAsync({
text,
createdAt: new Date(), // current time
});
Expand Down
8 changes: 4 additions & 4 deletions src/simple-todos/step05/imports/ui/Task.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { TasksCollection } from '../api/TasksCollection';
import './Task.html';

Template.task.events({
'click .toggle-checked'() {
async 'click .toggle-checked'() {
// Set the checked property to the opposite of its current value
TasksCollection.update(this._id, {
await TasksCollection.updateAsync(this._id, {
$set: { isChecked: !this.isChecked },
});
},
'click .delete'() {
TasksCollection.remove(this._id);
async 'click .delete'() {
await TasksCollection.removeAsync(this._id);
},
});
7 changes: 4 additions & 3 deletions src/simple-todos/step05/server/main.js
Original file line number Diff line number Diff line change
@@ -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) =>
await TasksCollection.insertAsync({ text: taskText });

Meteor.startup(() => {
if (TasksCollection.find().count() === 0) {
Meteor.startup(async () => {
if (TasksCollection.find().countAsync() === 0) {
[
'First Task',
'Second Task',
Expand Down
16 changes: 8 additions & 8 deletions src/simple-todos/step06/imports/ui/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,29 @@ Template.mainContainer.events({
});

Template.mainContainer.helpers({
tasks() {
async tasks() {
const instance = Template.instance();
const hideCompleted = instance.state.get(HIDE_COMPLETED_STRING);

const hideCompletedFilter = { isChecked: { $ne: true } };

return TasksCollection.find(hideCompleted ? hideCompletedFilter : {}, {
return await TasksCollection.find(hideCompleted ? hideCompletedFilter : {}, {
sort: { createdAt: -1 },
}).fetch();
}).fetchAsync();
},
hideCompleted() {
return Template.instance().state.get(HIDE_COMPLETED_STRING);
},
incompleteCount() {
const incompleteTasksCount = TasksCollection.find({
async incompleteCount() {
const incompleteTasksCount = await TasksCollection.find({
isChecked: { $ne: true },
}).count();
}).countAsync();
return incompleteTasksCount ? `(${incompleteTasksCount})` : '';
},
});

Template.form.events({
'submit .task-form'(event) {
async 'submit .task-form'(event) {
// Prevent default browser form submit
event.preventDefault();

Expand All @@ -49,7 +49,7 @@ Template.form.events({
const text = target.text.value;

// Insert a task into the collection
TasksCollection.insert({
await TasksCollection.insertAsync({
text,
createdAt: new Date(), // current time
});
Expand Down
8 changes: 4 additions & 4 deletions src/simple-todos/step06/imports/ui/Task.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { TasksCollection } from '../api/TasksCollection';
import './Task.html';

Template.task.events({
'click .toggle-checked'() {
async 'click .toggle-checked'() {
// Set the checked property to the opposite of its current value
TasksCollection.update(this._id, {
await TasksCollection.updateAsync(this._id, {
$set: { isChecked: !this.isChecked },
});
},
'click .delete'() {
TasksCollection.remove(this._id);
async 'click .delete'() {
await TasksCollection.removeAsync(this._id);
},
});
7 changes: 4 additions & 3 deletions src/simple-todos/step06/server/main.js
Original file line number Diff line number Diff line change
@@ -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) =>
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',
Expand Down
16 changes: 8 additions & 8 deletions src/simple-todos/step07/imports/ui/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Template.mainContainer.events({
});

Template.mainContainer.helpers({
tasks() {
async tasks() {
const instance = Template.instance();
const hideCompleted = instance.state.get(HIDE_COMPLETED_STRING);

Expand All @@ -48,26 +48,26 @@ Template.mainContainer.helpers({
return [];
}

return TasksCollection.find(
return await TasksCollection.find(
hideCompleted ? pendingOnlyFilter : userFilter,
{
sort: { createdAt: -1 },
}
).fetch();
).fetchAsync();
},
hideCompleted() {
return Template.instance().state.get(HIDE_COMPLETED_STRING);
},
incompleteCount() {
async incompleteCount() {
if (!isUserLogged()) {
return '';
}

const { pendingOnlyFilter } = getTasksFilter();

const incompleteTasksCount = TasksCollection.find(
const incompleteTasksCount = await TasksCollection.find(
pendingOnlyFilter
).count();
).countAsync();
return incompleteTasksCount ? `(${incompleteTasksCount})` : '';
},
isUserLogged() {
Expand All @@ -79,7 +79,7 @@ Template.mainContainer.helpers({
});

Template.form.events({
'submit .task-form'(event) {
async 'submit .task-form'(event) {
// Prevent default browser form submit
event.preventDefault();

Expand All @@ -88,7 +88,7 @@ Template.form.events({
const text = target.text.value;

// Insert a task into the collection
TasksCollection.insert({
await TasksCollection.insertAsync({
text,
userId: getUser()._id,
createdAt: new Date(), // current time
Expand Down
8 changes: 4 additions & 4 deletions src/simple-todos/step07/imports/ui/Task.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { TasksCollection } from '../api/TasksCollection';
import './Task.html';

Template.task.events({
'click .toggle-checked'() {
async 'click .toggle-checked'() {
// Set the checked property to the opposite of its current value
TasksCollection.update(this._id, {
await TasksCollection.updateAsync(this._id, {
$set: { isChecked: !this.isChecked },
});
},
'click .delete'() {
TasksCollection.remove(this._id);
async 'click .delete'() {
await TasksCollection.removeAsync(this._id);
},
});
8 changes: 4 additions & 4 deletions src/simple-todos/step07/server/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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,
Expand All @@ -22,7 +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',
Expand Down
12 changes: 6 additions & 6 deletions src/simple-todos/step08/imports/api/tasksMethods.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,39 @@ import { check } from 'meteor/check';
import { TasksCollection } from '../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);

if (!this.userId) {
throw new Meteor.Error('Not authorized.');
}

TasksCollection.update(taskId, {
await TasksCollection.updateAsync(taskId, {
$set: {
isChecked,
},
Expand Down
Loading