This shows you the differences between two versions of the page.
se:labs:05 [2024/11/12 13:00] gabriel.nicolae3103 [MongoDB Atlas] |
se:labs:05 [2024/11/12 13:07] (current) gabriel.nicolae3103 [Tasks] |
||
---|---|---|---|
Line 149: | 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. |