What causes the meteor database to be created/Find returns 0 documents


I have a new app using Meteor + Vue and I don’t have a meteor database, just a System one. What causes the meteor db to be created (the one with the accounts and user stuff)? I’ve tried meteor reset. I thought maybe creating a new collection would trigger it, but the insert fails with “not a function”.

Windows 10, Meteor 1.6.


So are you not even able to create a new collection? I’m not sure about the meteor db, it’s always just worked for me. I would imagine the user stuff (for example) would only create the collection when you add the accounts-base package though.

You could share some code if you want a hand though :slight_smile:


Creating a collection does not create the database unless there’s some operation on it, for instance, defining indexes or inserting a new document.

If you are starting your app with a meteor run command, then your database should automatically be available to you at mongodb:// which is meteor’s bundled database.

But if you are explicitly setting an environment variable like so MONGO_URL=mongodb:// meteor run setting an explicit url to your local mongodb istance, then it gets created in there.

Now, regarding the not a function error, I think you should be more explicit and descriptive of your problem, at least you should provide:

  • your code that you think should create the database, do the insert etc
  • the full error message and where you’re getting the error (the browser console or the server console in the terminal)

In wihch case I suspect we’ll likely be finding a small bug in your software.


Its been so long since I created a new Meteor app I forgot that accounts-base isn’t automatically installed. I added it and the appropriate pieces are now in the database.

@serkandurusoy, yes I didn’t include any code or enough info to diagnose the problem, that’s what happens when one posts at 2 am. But the actual problem I’m having is being unable to read from the database.

The mongo cli shows there are 2 documents in the trips collections (these were added manually):

{ "_id" : ObjectId("5a31b458f7f0f205c0af053f"), "Title" : "My first trip", "User" : "Ron", "Points" : [ { "Timestamp" : 123, "Latitude" : 1, "Longitude" : 1 }, { "Timestamp" : 123, "Latitude" : 2, "Longitude" : 2 }, { "Timestamp" : 123, "Latitude" : 3, "Longitude" : 3 }, { "Timestamp" : 123, "Latitude" : 4, "Longitude" : 4 } ] }
{ "_id" : ObjectId("5a31b496f7f0f205c0af0540"), "Title" : "My second trip", "User" : "Ron", "Points" : [ { "Timestamp" : 123, "Latitude" : 1, "Longitude" : 1 }, { "Timestamp" : 123, "Latitude" : 2, "Longitude" : 2 }, { "Timestamp" : 123, "Latitude" : 3, "Longitude" : 3 }, { "Timestamp" : 123, "Latitude" : 4, "Longitude" : 4 } ] }

I’ve hacked down the code into something really simple:

try {
 foo = new Meteor.Collection('trips');
   insert: function() { return true; },
   remove: function() { return true; },
   update: function() { return true; }

 x = foo.find();
 console.log('foo cursor:', x.count(), x);

 foo.insert({Title: "foo"},
   function(err, res) {
   if (err) {
     console.log("Insert failed with ", err.reason);
   } else {
     console.log("1 record inserted");
} catch(err) {
 console.log("error:", err.message);

insecure is installed (yes, yes, I know) but even so I added the allow call to enable client side writing. The log after the find says:

foo cursor: 0 Cursor {collection: LocalCollection, sorter: null, matcher: Matcher, _selectorId: undefined, skip: 0, …}

even though there are 2 documents. The insert prints

Insert failed with  Method '/trips/insert' not found

This is pretty much right out of the Meteor simple ToDo app so either there is something going on with the Vue integration or I’m doing something stupid.

And just a note, the actual code is using publish/subscribe rather than a raw client-side find(), but the embedded ‘find()’ also returns 0 documents.


OK, so you are probably running this whole code on the client side, but for meteor’s data system to work as you intend it to, you need to place the

   insert: function() { return true; },
   remove: function() { return true; },
   update: function() { return true; }

part on the server and

foo = new Meteor.Collection('trips');

part on both client and the server so that the collection and its insert/update/remove/upserts methods are defined on the server, too!


Do you have a public repo, or is it possible to create a basic reproduction?


@copleykj, no we don’t have a public repo. We are still negotiating financing and don’t know yet if the app will be open-source or not.

BUT, @serkandurusoypointed me in the right direction. I don’t actually care about the in-line find() or insert(), I need the publish/subscribe to work. I looking at my publish code I realized that the file wasn’t being imported by server/main.js due to a typo. Fixing that fixed the publish/subscribe. As I said, something stupid. Thanks to all who replied and thanks for putting up with me.