mongodb - What is mongoose actually opening here? -


i in beginning stages of learning mean stack.

i've created first node app, using mongoose , mongodb.

in node.js code, have following:

mongoose.connect('mongodb://localhost/meantest1'); 

i can create documents , find them fine, however, i'm not entirely sure it's storing data?

app.get('/api/test', function (req, res) {     test.create({         name: "joe schmo"     }, function() {         test.find(function (err, tests) {             res.json(tests);         })     }); }) 

in mongo shell, if execute

use meantest1 db.test.find() 

it returns data entered in shell, nothing app.

can explain going on here?

also, there better app querying mongo shell??

mongoose automatically pluralizes collection names when register model. in case model name of test converted collection name of tests.

if want prevent pluralization, or need attach model existing collection that's not pluralized, may pass collection name third argument mongoose.model method:

mongoose.model('test', testschema, 'test'); 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -