Skip to content
New issue

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

How to use Minimongo, Please share any reference? #5

Closed
technicalbirdVayuz opened this issue Jul 6, 2022 · 8 comments
Closed

How to use Minimongo, Please share any reference? #5

technicalbirdVayuz opened this issue Jul 6, 2022 · 8 comments

Comments

@technicalbirdVayuz
Copy link

No description provided.

@technicalbirdVayuz
Copy link
Author

Getting Error as, Minimongo.LocalCollection is not a constructor, Trying with

var User = new Minimongo.LocalCollection("data")

@jamesgibson14
Copy link

Try new LocalCollection(null) or new LocalCollection('data') that is what I use.

@technicalbirdVayuz
Copy link
Author

Hi @jamesgibson14 ,

Does this package provide reactivity? I have tried it but its only adds in local collection only, whenever I want to retrieve the data using the helper function, getting a blank array.

@jamesgibson14
Copy link

Yes it does, in your helper just do something like:

getUser( userId ){
  return User.findOne({_id: userId})
}

@technicalbirdVayuz
Copy link
Author

technicalbirdVayuz commented Jul 7, 2022

Attaching the code, please have a look

var User = new LocalCollection("data")

Template.listingLayout.onCreated(function(){
  User.insert({"title":"Hello"})
});

Template.listingLayout.helpers({
  data: function () {
    return User.find({}).fetch();
  },
});

document.addEventListener("dataReceived", function (data) {
  User.insert({ title: "New Data" });
 });

Dispatching event from the client side, but helper function returns only 1 document. Also, I am using it with webpack

@technicalbirdVayuz
Copy link
Author

Changed to User.find({}) only, its working now, Thanks!

@harryadel
Copy link
Owner

Thank you @jamesgibson14 for your effort <3

@jamesgibson14
Copy link

jamesgibson14 commented Jul 8, 2022

No problem, I am glad @technicalbirdVayuz figured it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants