12 mongo db_and_nodejs

Post on 21-Apr-2017

66 views 0 download

Transcript of 12 mongo db_and_nodejs

MongoDB and NodejsAhmed Elbassel

Email: elbassel.n13@gmail.com

Skype: ahmed_elbassel

MongoDB and Nodejs- MongoDB driver- Data Types- Connecting to MongoDB- Inserting Data with Node.js- Find or Query data with Nodejs- Update with Nodejs- Remove with Nodejs

MongoDB Driver- https://docs.mongodb.com/ecosystem/drivers/

Data types- Double- String- Object- Array- Binary data- Object id- Boolean- Date- Null- Regular Expression- Timestamp- 64-bit integer

3. Connecting to MongoDB- Go to the directory of your app.- Open a terminal > npm init- Create app.js file.- Run your app.

- Got an error :D- You have to install MongoDB driver- > npm install --save mongodb

4. Insert data with Node.js

5. Find or Query data with Node.js- Query by a field in a document:

5. Find or Query data with Node.js- Query by a field in subdocument:

5. Find or Query data with Node.js- Query by a field in array:

- Query by a field in array:

5. Find or Query with Nodejs- And operator:

- Or Operator

6. Update data with Node.js- Update Specific fields in one document to update all matched use

updateMany:

6. Update data with Node.js- Update Embedded field:

- Update Embedded field:

7. Remove data with Node.js- Remove one document:

- Remove all document:

For more information:

http://mongodb.github.io/node-mongodb-native/2.0/api/index.html

Questions