Hi there, i facing problem with data retriving from mongodb my data from mongo colletions is not working
what ever the app maybe the data is not retriving can any body help
Please post code examples of what you’re trying and what isn’t working.
`
import { Template } from ‘meteor/templating’;
import { ReactiveVar } from ‘meteor/reactive-var’;
import {Mongo} from ‘meteor/mongo’;
import ‘./main.html’;
Resolutions = new Mongo.Collection(“resolutions”);
Template.resolution.helpers({
resolutions : function(){
return Resolutions.find();
}
});
simple-todo app
body.js Code:-
import { Template } from ‘meteor/templating’;
import ‘./body.html’;
import ‘…/api/tasks.js’;
Template.body.helpers({
tasks: function() {
return Tasks.find({},{sort : { createdAt : -1 }});
},
});
Template.body.events({
‘submit .new-task’(event){
// Prevent default browser form submit
event.preventDefault();
// Get value from form element
const target = event.target;
const text = target.text.value;
// Insert a task into the collection
Tasks.insert({
text:text,
createdAt: new Date(), // current time
});
// Clear form
target.text.value = ‘’;
},
});`
I just fixed up my problem by writting up the code of data base in
server/main.js code
import { Meteor } from ‘meteor/meteor’;
import { Mongo} from ‘meteor/mongo’;
Meteor.startup(() => {
// code to run on server at startup
Tasks = new Mongo.Collection(‘tasks’);
});
thanks for your help guys