How to access a collection in browser console which is exported in lib?

This is my lib/collections.js-

import {Mongo} from 'meteor/mongo';
export const Posts = new Mongo.Collection('posts');

but calling Posts on my browser console throws the error -
VM762:1 Uncaught ReferenceError: Posts is not defined(…)

and redeclaring it there with Posts = new Mongo.Collection('posts') throws an error -
collection.js:220 Uncaught Error: There is already a collection named 'Posts'(…)

How do I access my Posts collection in my browser console?

You’re going to have to have to put into a global. Something like:

import {Mongo} from 'meteor/mongo';
export const Posts = new Mongo.Collection('posts');
GlobalPosts = Posts;
3 Likes

Hey!

I updated to Meteor 1.4 and now this is not working. Could you please tell how to make Posts global now?

Hi!
Me too I wanted to access some db collections in the browser console but I can’t. I export a const for the different Collection I made. I can’t acess to it throught the browser console.

Is that another way to do that? If not, is that mean that there is no “security” issue? Why we have to publish and subscribe… ? I’m a little bit confused…