Works in meteor shell but not in javascript? [SOLVED]


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
_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
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:

  { extention: 'jpg' },
    fields: {
      extention: 0, 
      count: 1


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:


  { extention: 'jpg' },
    fields: {
      extention: 0, 
      count: 1


function overview($document){
	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!