Node.js + Express - Tutorial - Insert and Get Data with MongoDB

preview_player
Показать описание
Let's write Node/Express code to insert data into our MongoDB as well as retrieve it and render it to the screen.

----------

----------

• Follow @maxedapps and @academind_real on Twitter

See you in the videos!

----------

Рекомендации по теме
Комментарии
Автор

Vielen vielen Dank! Hat mir entscheidend bei einem Problem geholfen, für das ich bereits 2 Wochen eine Lösung suchte und ganz Youtube durchreiste.. bis ich wieder bei einem Deutschen (?) angekommen bin, der halt auf Englisch seinen Content produziert. In der Heiterkeit endlich weitergekommen zu sein, ein echter Brüller! Merci beaucoup!

werwolfischekatharsis
Автор

If someone gets a error "db.close()" is not a function, please use "client.close()" as initially we created a client object not a db object,
we created a db object out of client object.
So we need to close a client object to end the connection.
Hope it helps :)

venkateswarank
Автор

Your lessons are so easy to understand. Thankyou.

baretings
Автор

For mongodb version >= 3.0. I change the connection to the database like this because the database variable in this version is actually the parent database object :

var url = 'mongodb://localhost:27017'
....
router.get('/get-data', function(req, res, next) {
mongo.connect(url, function(err, database) {
assert.equal(null, err)
var dbTest = database.db('test')
var cursor =
....
})
})

For Post is the same case. Great tutorial max very thanks.

simongonzalez
Автор

Your tutorials are good. And your pace going forward is just right. Not too fast nor too slow. Thank you.

menandmice
Автор

Really helping me get through my current University module with NODE JS and Express with Mongo... Thanks very much dude :)

Henry-utnx
Автор

Hi.
i am getting error with mongodb(assertion error) fail to connect to server on first on first connect. i don't know whats the problem. i am following every step but db not working. any idea.
thanks for help in advance

usmansiddiq
Автор

Max is good teacher/instructor. Thank you!

menandmice
Автор

Am trying to insert data but when i click insert, the browser is displaying not found message, what might be the problem?

gabrielgitonga
Автор

Just as a curiosity how secure is something like this? Sure the IDs are pretty large but is it considered good practice to allow a user to directly delete things from a database like this if one were building something like this in a production setting?

noonansean
Автор

Hey something to note. mongo.connect() is creating a connection pool, 5 in your case. The idea behind this connection pool is that you don't have to open a connection each time like you are.

alexmc
Автор

let me tell you one thing ! u r an amazing tutor as well apart from being a great developer :-)

kashyap
Автор

For MongoDB version above 3.0.0,

_var url = 'mongodb://localhost:27017';_

_mongo.connect(url, function(err, client) {_
_..._
_var db = client.db("test");_
...
_client.close();_
_}_

It will resolve the below error :
-TypeError: db.collection is not a function-

CoolBoi
Автор

I have followed the same steps am getting an error as db.collection is not a function. Can you please help me out of these.

vijayreddy
Автор

Hiii

If we want to take multiple values >15
From a text box on a web page

How we should design the schema

shanigarammanideep
Автор

Mannn!!! Where were you? You solved my big problem. Thank you!

shahfaisal
Автор

LOVE your NodeJS tutorials! Do you foresee NodeJS doing well in the corporate realm? Wondering if I should keep learning NodeJS or stick with PHP? Will NodeJS go away and fade out at some point?... or do you think it is here to stay?

deveagle
Автор

sometimes it prints item inserted but no record insert in table so how we can fix that ; same issue with update

dhanushantbishnoi
Автор

My cursor.foreach is not ending. I even trued promise and then functions. Still the array returns the undefined value.

shanksakagami
Автор

i have completed code which you have teached .but i got error collection is not a function .iam using mongo 3.6.2 please kindly tell me the solution

ashu_recitation