Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
Jonathan GrieveTreehouse Moderator 91,250 Points
Using load() with Mongo
Just a quick question with the load command in MongoDB,
I had a lot of trouble when following the video trying to connection to seed.js, probably because I'm working in a different setup to a Mac.
Then I remembered about the data/db directory and placed my project in there.
It worked, and I was able to run commands on it.
But it never worked unless I placed the seed file in that directory even though it looked liked Huston was able to run commands from other locations.
Why is this? I know we're looking for relative paths from the current working directory, but that's different from just the data/db directory.
I know this conversation is rather old, but I got stuck with this, so in case someone else is using Windows and is stuck...
In my case, it wouldn't load the file when I used the load('full_path_to_file') as suggested above, however, after I exited all the folders and then used cd('path_to_file_folder') and then load('file'), it actually loaded it.
I got it to work by just putting in the absolute file path. ex: load('C:/projectfolder/seed.js')
I think in the video he changes the directory he is in, but he does it very fast. (FYI - I am working on windows through ConEmu)
Kjetil-Lennart A. Lorentzen13,390 Points
I didn't get anything to work, i copy pasted the absolute path from windows explorer. BUT! When i changed all the "\" to "/" it worked. I did like ieva graudule, cd('e:/the/directory') then load('seed.js')
I hope this helps someone