Week 3 Homework - Beau Barth - w3-mongo#23
Open
bbarth86 wants to merge 3 commits intopce-uw-jscript400:masterfrom
Open
Week 3 Homework - Beau Barth - w3-mongo#23bbarth86 wants to merge 3 commits intopce-uw-jscript400:masterfrom
bbarth86 wants to merge 3 commits intopce-uw-jscript400:masterfrom
Conversation
bwreid
reviewed
Jul 26, 2019
|
|
||
| * **Your Answer:** | ||
|
|
||
| ---A `document` represents a record/collection of data. In mongoDB, it is stored in BSON format, which is similar to JSON. A `collection` is a grouping of documents, usually grouped for a shared or similar purpose, like transactions, or pricing/inventory collections. A `database` contains both documents, invidiually or in collections. |
Collaborator
There was a problem hiding this comment.
A database will primarily contain collections as opposed to documents.
|
|
||
| * **Your Answer:** | ||
|
|
||
| ---It is used to establish a unique ID for each record. By default however, MongoDB (Mongoose? This was going to be checked/confirmed) will create a unique ID even if this statement is not present. |
Collaborator
There was a problem hiding this comment.
Mongo sets the ID by default. With both Mongoose & MongoDB, you can disable this.
|
|
||
| * **Your Answer:** | ||
|
|
||
| ---You can resolve this issue by adding `useFindAndModify: true` to your mongoDB connection statement . If i am understanding the Mongoose documentation correctly, this statement is added in order to force Mongoose to use MongoDB driver's `findOneandUpdate()` function instead of MongoDB driver's `findAndModify()` function. Is that correct? |
|
|
||
| * **Your Answer:** | ||
|
|
||
| ---`Model.create()` failed to return a response, even though the creation of the document was successful in the DB. I am not entirely sure that i understand the error in the terminal, but it seems as though i am dealing with a promise rejection and would need to use something like `.catch()` to handle with an error message, function, etc. Is it because ``Model.create()` is not returning a query? |
Collaborator
There was a problem hiding this comment.
Correct, Model.create() returns a different type of object so you can't call .select() on it.
|
|
||
| * **Your Answer:** | ||
|
|
||
| --- I see the specific messaging coming back in the terminal, but i'm unclear on how to take the `message` key/value pair and parse it to my error message. |
Collaborator
There was a problem hiding this comment.
I believe the error should have a messages key that is an array of all the errors that occurred. Looping through this will give you access to the individual messages.
|
|
||
| * **Your Answer:** | ||
|
|
||
| --- So I consistently ran into the 400 error defined in my try/catch statements, but when checking Atlas I can see the document was created. My series.js file is also uploaded for reference. Why might this be? To answer the question however, the `_id` field was automatically created by Mongoose. |
Collaborator
There was a problem hiding this comment.
Let me know if you're still having this issue. I would try and log out the error your receiving in the catch portion to narrow this down.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.