oke, this is driving me nuts…
in the Meteor shell via terminal:
db.overview.findOne({“extention” : “jpg”}, {}, {fields: {“extention”: 0, “count”: 1}}).count
returns: 1000
in javascript:
full_overview.findOne({“extention” : “jpg”}, {}, {fields: {“extention”: 0, “count”: 1}}).count
returns:
_debugdebug.js:41Exception in queued task: added@http://localhost:3000/app/app.js?hash=3be3d66dff41c961c7d8d244bce77c2747204b48:198:115
http:// localhost:3000/packages/minimongo.js?hash=f636910493635f8b630c45a605cd39ce5db2d58f:409:18
runTask@http://localhost:3000/packages/meteor.js?hash=ae8b8affa9680bf9720bd8f7fa112f13a62f71c3:721:12
flush@http://localhost:3000/packages/meteor.js?hash=ae8b8affa9680bf9720bd8f7fa112f13a62f71c3:749:17
drain@http://localhost:3000/packages/meteor.js?hash=ae8b8affa9680bf9720bd8f7fa112f13a62f71c3:757:17
insert@http://localhost:3000/packages/minimongo.js?hash=f636910493635f8b630c45a605cd39ce5db2d58f:617:27
update@http://localhost:3000/packages/mongo.js?hash=bc4cc4faf274ce28cefc812067aa65c0d4025ed4:240:36
http:// localhost:3000/packages/ddp-client.js?hash=b5f1b97df6634673c68f37914ae9f4c3231c438e:3597:53
http:// localhost:3000/packages/ddp-client.js?hash=b5f1b97df6634673c68f37914ae9f4c3231c438e:4385:25
forEach@[native code]
i have no idea what this means, nor do i understand why via shell it works and not via javascript!
Minimongo works a bit differently than Mongo. Check the Meteor Collection.findOne docs to see the accepted criteria. In your case you’ll likely want something like:
full_overview.findOne(
{ extention: 'jpg' },
{
fields: {
extention: 0,
count: 1
}
}
).count
I read the meteor documentations for about an hour but couldn’t figure out what was going wrong.
and even with your alterations, I still get the same error messages as I stated previously.
i connected to my mongodb via this code:
import { Mongo } from 'meteor/mongo';
export const full_overview = new Mongo.Collection('overview');
maybe something wrong there?
What do you see when you:
console.log(full_overview);
console.log(full_overview.findOne(
{ extention: 'jpg' },
{
fields: {
extention: 0,
count: 1
}
}
));
overview("jpg");
function overview($document){
console.log(full_overview);
console.log(full_overview.findOne({ extention: $document }));
}
returns the following
[Log] Collection {_makeNewID: function, _transform: null, _connection: Connection, _collection: LocalCollection, _name: "overview", …} (app.js, line 171)
[Log] undefined (app.js, line 173)
Please, keep in mind though, I started using meteor like, 2 weeks ago and only did the tutorial.
I am quit capable of creating proper javascript/jQuery code, but the complexity of meteor just bogles my mind!
What i’m trying to do is look a collection for all the documents with an extention, and than push the amount to a different collection+have it update every time a new document is added to the collection with an extention.
(just noticed I misspeld extention…)
So all fixed then or was the spelling error just in your code sample?
multiple spelling errors… Thanks anyway!