We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This is My JS Code
tasks = new SQL.Collection("tasks"); if (Meteor.isClient) { tasks.createTable({ id: ['$number'], text: ['$string'], checked: ['$bool', {$default: false}], createdAt: ['$datetime'] }); Template.body.helpers({ tasks: function () { return tasks.select().fetch(); } }); Template.body.events({ "submit .new-task": function (event) { event.preventDefault(); var text = event.target.text.value; tasks.insert({ text: text, createdAt: new Date() }).save(); event.target.text.value = ""; } }); Template.task.events({ "click .toggle-checked": function () { tasks.update({ id: this._id, "checked": !this.checked }).where("id = ?", this.id).save(); }, "click .delete": function () { tasks.remove().where("id = ?", this.id).save(); } }); } if (Meteor.isServer) { tasks.createTable({ id: ['$number'], text: ['$string'], checked: ['$bool', {$default: false}], createdAt: ['$datetime'] }).save(); tasks.publish('Tasks', function () { return tasks.select().save(); }) }
this is my html Code
<head> <title>Todo List</title> </head> <body> <div class="container"> <header> <h1>Todo List</h1> <form class="new-task"> <input type="text" name="text" placeholder="Type to add new tasks" /> </form> </header> <ul> {{#each tasks}} {{> task}} {{/each}} </ul> </div> </body> <template name="task"> <li class="{{#if checked}}checked{{/if}}"> <button class="delete">×</button> <input type="checkbox" checked="{{checked}}" class="toggle-checked"/> <span class="text">{{text}}</span> </li> </template>
and this is the error log :
TypeError: Cannot call method 'query' of null
please help me i cant find the mistake;
thanks in advance
The text was updated successfully, but these errors were encountered:
Hi @lrAlval . I think the problem emerges from these lines, that get executed on the server.
tasks.createTable({ id: ['$number'], text: ['$string'], checked: ['$bool', {$default: false}], createdAt: ['$datetime'] }).save();
No need to call .save() when creating a table. You can do just the same as you do on the client. Let me know if this fixed the problem.
.save()
Sorry, something went wrong.
No branches or pull requests
This is My JS Code
this is my html Code
and this is the error log :
TypeError: Cannot call method 'query' of null
please help me i cant find the mistake;
thanks in
advance
The text was updated successfully, but these errors were encountered: