Facing problem with retreving data from mongodb


#1

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


#2

Please post code examples of what you’re trying and what isn’t working.


#4

`

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();
}
});


#5

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 = ‘’;
},
});`


#6

I just fixed up my problem by writting up the code of data base in

server/main.js code :smile:

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 :smiley: