I\'m following the telescope tutorial.
Assuming you had a username of username
, a password of PASSWORD
, a database named test
, and a hostname of hatch.mongohq.com
:
$ mongo hatch.mongohq.com:27017/test -u username -p PASSWORD
$ MONGO_URL="mongodb://username:PASSWORD@hatch.mongohq.com:27017/test" meteor
You should define your Meteor collections outside of the client
directory so they can be used on both the client and the server. See this for more details.
You will find that connecting to a remote database is much slower than connecting locally, so it's generally not recommended for development.
Meteor creates a dev database for you when it starts. This also affords you the very helpful commands: meteor reset
and meteor mongo
, to reset, and connect to said database.
Create a file on the server for initialization - e.g. server/initialize.js
. When the server starts you can add users or other documents which do not yet exist. For example:
Meteor.startup(function() {
if (Meteor.users.find().count() === 0) {
Accounts.createUser({
username: 'jsmith',
password: 'password',
profile: {
firstName: 'John',
lastName: 'Smith'
}
});
}
});