0

I am learning node and mongodb

My app is working fine (Its is online tutorial app)

I have two Question

// define model =================
var Todo = mongoose.model('Todo', {
    text : String
});


// create todo and send back all todos after creation
app.post('/api/todos', function(req, res) {

    // create a todo, information comes from AJAX request from Angular
    Todo.create({
        text : req.body.text,
        done : false
    }, function(err, todo) {
        if (err)
            res.send(err);

        // get and return all the todos after you create another
        Todo.find(function(err, todos) {
            if (err)
                res.send(err)
            res.json(todos);
        });
    });

});

I hope you understand my code (Its todo adding app)

1) Is 'Todo' is collection in mongoDB ? I typed on cmd db.collection.find() but nothing result ? , Which command i use on cmd to see data here

2) Can I open DB data storage file in my editor with any tool ?

Online tutorial app link Thanks

Hunter
  • 1,515
  • 4
  • 15
  • 25

1 Answers1

1

First you have to select the database.

use database-name

You can find the list of collections in database using the following command.

show collections

You can find the list for databases using the following command

show dbs

Then use the db.collection.find() command.

use help command to find list of commands.

Vishnu
  • 11,614
  • 6
  • 51
  • 90
  • Success , and 2) Can I open DB data storage file in my editor with any tool ? – Hunter Aug 22 '15 at 17:11
  • I am not sure. refer this link http://stackoverflow.com/questions/5961145/changing-mongodb-data-store-directory – Vishnu Aug 22 '15 at 17:28
  • @Hunter I use the program MongoVUE to review and manage my MongoDB databases both locally and on production sites like OpenShift and Heroku. – Michael Blankenship Aug 22 '15 at 19:05