Connecting mongodb with meteor app

In terms of the plumbing required to get data where you want it, I suggest reading this:

It really helped me get an understanding of where data lives and how it moves inside a Meteor app :slight_smile:

1 Like

thank you so much @coagmano, really appreciate it.

Can you help me why my app always crash after i put → import { eventlogin } from '…/…/api/eventlogin/eventlogin.js in my server\publication.js? i have done what @minhna told me, i changed export default eventlogin to export const eventlogin. @coagmano

That I don’t know, it looks like it should work

Perhaps try with an absolute import?
Meteor allows you to import from the project root by starting the path with / like so

import { eventlogin } from '/imports/api/eventlogin/eventlogin.js';

Otherwise, double check that the files are all saved and the names are capitalised correctly

The same is happening here

if i make it as comment, the app running as expected.

the app should show like this

at the end of eventlogin.js, try export like this:
export { eventlogin };

@minhna, it won’t be anything about the import or export style, that would give an undefined style error instead of a straight up “module not found”, this looks like a path issue

Not that I have any clue WHY this is happening haha

@sikippy can you pop this on github so we can take a look?

1 Like

1 Like

hahaha LOL @minhna, @minhna and @coagmano anyway thanks for helping. That’s ok @coagmano, i will sent the code to my github, soon after i push it, i will let you know.

@coagmano, please take a look at https://github.com/sikippy/gitfullcalendar.

Thank you for your precious time.

I couldn’t replicate your “Module not found” error either either the relative or absolute path to eventlogin.js
Did you try a meteor reset on the command line?

I did notice that the error in the publications was because you named the publish function eventlogin which meant that the variable eventlogin pointing to the collection was overwritten with a pointer to the function.
To fix, you just have to name it something else (or use an anonymous function)

in Login.js, there were lots of eventLogin and eventlogin calls, with different capitalisation. This would have definitely been giving you errors.
Everything was fine after renaming all the eventLogin to eventlogin

Well, it still doesn’t insert the record, but that is now the intended behaviour, since you have not allowed client side mutations.
If you manually insert the user into mongo, the count does update on the server.

I noticed that you already have Meteor’s accounts system installed as well as the semantic-ui stlyed components that provide all the login/registration etc forms for you.

While it might be a useful exercise to try your own auth system, it will be much easier to use the components, collections and methods provided by those packages.
Using Meteor’s accounts system will mean that when you want the current user’s ID or record, or want to verify a method call on the server that Meteor will automatically tell you which user is attempting to perform the action.

Is there a reason you are using a really old version of Meteor? I would definitely suggest new projects should use the newest version of Meteor available

I also noticed a whole host of other issues that I won’t mention now, but they all point to a need to better understand how reactivity works and how meteor works.
I strongly advise going through the official tutorial and/or meteor-tuts or Level Up Tuts

I also strongly advise reading the docs properly when using a new module or API in Meteor and reading the Meteor Guide.
On the first week of my current job I was told to read through the Meteor Guide and it really jump-started my understanding of Meteor, it’s incredibly helpful.

Always happy to help out further on here with clarifications on individual concepts or debugging individual issues :slightly_smiling_face:

2 Likes

Thank you for enlightenment @coagmano, i should learn a lot from an experience user like you. I will read your references, it will help me find the lost treasures, hahaha :wink:

2 Likes