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');
foo.allow({
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.