Mongo collections not available?


#1

My Mongo collection is clearly visible when I inspected in Chrome console

But within the meteor mongo shell it is still empty?

/lib/collections.js

var Schemas = {};

Schemas.FutureTask = new SimpleSchema({
    number: {
        type: String,
        label: "TICKET_NUMBER",
        max: 10, 
        index: true,
        unique: true,
        optional: true
    },
    userid: {
        type: String,
        label: "USER_ID",
        max: 20,
        optional: true 
    },
    assigned_to: {
        type: String,
        label: "ASSIGNED_TO",
        max: 50,
        optional: true
        // optional: false
    },
    assignment_group: {
        type: String,
        label: "ASSIGNMENT_GROUP",
        max: 30,
        optional: true /
    },
    start_date: {
        type: String, 
        label: "START_DATE",
        max: 19,
        optional: true 
    },
    end_date: {
        type: String,
        label: "END_DATE",
        max: 19,
        optional: true 
    },
    access_rights: {
        type: String,
        label: "JOB_STATUS",
        max: 30,
        optional: true
    },
    returned_status: {
        type: String,
        label: "JOB_STATUS",
        max: 30,
        optional: true
    },
    count: {
        type: String,
        label: "COUNT",
        optional:true
    }

});

var Collections = {};

FutureTasks = Collections.FutureTasks = new Mongo.Collection('future_tasks');

FutureTasks.attachSchema(Schemas.FutureTask);

$ meteor mongo

use future_tasks

db.future_tasks.find()

empty?


#2

You don’t need this. Here you are saying to switch to a new database called future_tasks. The meteor mongo shell automatically switches you into the correct database.


#3

Thanks Rob,

all the tutorials, first thing they do is type

use…

But my app has 2 collections, so I still need to

use anotherdB… ?


#4

No.

Collections are like tables in a SQL database. You are using one database with many collections.

meteor mongo
> show collections

will give you a list of all the collections (tables) in your database.

> db.collection1.find()
> db.collection2.find()

to see the documents in two collections.