Differences

This shows you the differences between two versions of the page.

Link to this comparison view

se:labs:05 [2024/11/12 12:48]
gabriel.nicolae3103 [MongoDB Atlas]
se:labs:05 [2024/11/12 13:07] (current)
gabriel.nicolae3103 [Tasks]
Line 128: Line 128:
 {{:​se:​labs:​mongodb_connection_string.png?​700|MongoDB User}} {{:​se:​labs:​mongodb_connection_string.png?​700|MongoDB User}}
  
-Make sure to replace <​db_password>​ with the password that you set up earlier. Also, you need to add **SE2024** in your connection string like this <​db_username>:<​db_password>​@cluster0.bpou2.mongodb.net/​**SE2024**?​retryWrites=true&​w=majority&​appName=Cluster0. SE2024 represents our database name, if you chose another name for your database, use that.  ​+Make sure to replace <​db_password>​ with the password that you set up earlier. Also, you need to add **SE2024** in your connection string like this  
 +<​code>​ 
 +mongodb+srv://​<​db_username>:<​db_password>​@cluster0.bpou2.mongodb.net/​SE2024?​retryWrites=true&​w=majority&​appName=Cluster0. 
 +</​code>​ 
 + 
 +SE2024 represents our database name, if you chose another name for your database, use that. Your connection string will be different, so don't just copy and paste the connection string from above! ​ 
  
 <note tip> <note tip>
Line 144: Line 149:
   - Look through the source code to see how Mongoose is utilised to connect to our database and create our Schema. The files you need to watch for are db/​mongoose.ts and model/​todo.ts   - Look through the source code to see how Mongoose is utilised to connect to our database and create our Schema. The files you need to watch for are db/​mongoose.ts and model/​todo.ts
   - Update the MongoDB connection string in **.env.local** with your own.   - Update the MongoDB connection string in **.env.local** with your own.
-  - Go to Atlas and create one document to test that the connection and find query works. The document needs to have a **text** and a **completed** field. ​+  - Go to Atlas and manually ​create one document to test that the connection and find query works. To create a document go to Clusters -> Browse Collections -> Select the collection -> Insert document. The document needs to have a **text** ​(string) ​and a **completed** ​(boolean) field. MongoDB will automatically assign an _id field.
   - Go to actions.ts and look at the new getItems() function, if you did everything correctly until now your ToDo list should contain one item (the document that you created earlier).   - Go to actions.ts and look at the new getItems() function, if you did everything correctly until now your ToDo list should contain one item (the document that you created earlier).
   - Look at the new createItem() function, by creating a new todo item, a new document should be inserted in our collection.   - Look at the new createItem() function, by creating a new todo item, a new document should be inserted in our collection.
se/labs/05.1731408502.txt.gz · Last modified: 2024/11/12 12:48 by gabriel.nicolae3103
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0