I used to be able to use the Chrome Tools Console to type in Mongo commands on my Meteor app and see the results. Stuff like, Collection.findOne({name: "foo"}). It is also done this way in the tutorials on the Meteor site.
Now, for any mongo commands, I just get [collection] not defined. It makes debugging MUCH more difficult.
Perhaps something changed in the last few releases? Any insights?
Since Meteor 0.6.0 individual files are variable scoped. So if you have a collection defined via
var Collection = new Meteor.Collection("collection");
It won't be visible on the console anymore (but it will be visible in the file its defined in)
The workaround is to define the file globally which is just removing the var:
Collection = new Meteor.Collection("collection");
Then you should be able to access it on the chrome js console once again
Related
I was wondering how I can create a topic in the console of fire base. I see there is android code to do it from the application but that takes time to reflect on the console. I don't even know where to look if it was created. Also can this be done in Javascript compared to java?
Example code for JS would be nice if I cannot do it through the console.
Thanks,
You don't need to do anything in the console to create a topic. Just start using it by string name on both the server and client, and it will just work.
cd ~/my-package
meteor test-packages ./
open localhost:3000
I can't seem to use the JS console: Even though Meteor can be logged from a client test file, when I enter it in the console, I get VM10740:1 Uncaught ReferenceError: Meteor is not defined. Same goes for other objects like Accounts.
I'd like access to these variables and those defined in my package and tests file in order to debug my tests.
EDIT: In the client test file, this works:
window.Meteor = Meteor
window.Accounts = Accounts
...
Is there a better way? Or at least a way that automatically goes through all globals? Trying this caused a refresh loop: _.extend(window, this)
Started meteor+mongodb yesterday so probably it is a simple thing:
When we create a new project with meteor create appname and then run it with meteor run Meteor automatically creates a simple project for us, right? (that simple app with a button and a counter).
Ok, based in the fact that all meteor project has his own mongodb associated, how can I take a look on the default db created? I´d like to use a command on console to check the collection structure created by default..
I´ve tried: show dbs | show collections | Mongo.Collection();
But always get the same error message: use "new" to construct a Mongo.Collection.
Yeah, I know that. I know how to create a new mongodb and then create a collection and insert values on it.
But what about that counter that is already working? It´s storaging his values in a collection already created, right?
I´d like to access it... and maybe modify.. not create one db for my own at this moment... How can I do that?
Thanks
meteor mongo command gives you access to mongo console.
From official documentation:
meteor mongo
Open a MongoDB shell on your local development database, so that you
can view or manipulate it directly.
...you must already have your application running locally with meteor run.
http://docs.meteor.com/#/full/meteormongo
So, I have started to test Meteor on a Nitrous.io box in the cloud. I used to enter a test record by typing it directly into the Chrome browser console, like:
Projects.insert({name:'First Project',client:'Project Central',duedate:new Date(),status:'On Hold'});
However, that does not work on Nitrous.
So, how do I add a test record in my meteor collection to work on?
Who can help me in the right direction? Much appreciated.
After you run meteor run in a Nitrous.io console,
open up another console and run meteor mongo.
Then you can type in a db.Projects.insert(...) or other mongoDB command.
There might be the case if you removed insecure package, insert will not work from browser client.
Check if the 'insecure' package installed or not using following command
meteor list --using
which will list the packages which are used by the meteor app.
I have few problems with meteor. Is there any need to create database using "use mydb" programmatically. I didn't used it so far and i'm directly creating collections and applied CRUD operations on them. But, i saw db.collection.find() like things few times and when i'm trying to apply on my collection it is showing error like db is not initialized how to initialize it. Here my main problem is, I tried to import some content from .json file to my collection. which is possible using database only(i thought). I can import them from shell like this
mongoimport --db test --collection mobiles <products.json --jsonArray
and how to import them without db.
You would have to show some code to see what exactly the issue is.
Meteor uses MongoDB so the schema doesn't need to be strictly created for things to work, like as would be done in MySQL or a traditional SQL type database. You can just insert documents and if the collection doesn't exist, or the database doesn't exist it would be created then without explicitly being created separately.
To import your files you need to import to your meteor database running at port 3002 (if your meteor app is running on port 3000 - meteor app port + 2). Something like this should work, the database is meteor
mongoimport --db meteor --host localhost:3002 --collection mobiles --jsonArray --file production.json
(Not sure about your file structure so i'm assuming its --jsonArray --file production.json). You could check out the docs at http://docs.mongodb.org/v2.4/reference/program/mongoimport/ for more details
So again you wouldn't need to create a database when you do this, using the --db argument would load things into meteor. If it doesn't exist it would automatically create it as you use it.