What are the pros and cons of using embedded documents when you can simply use an array datatype? Both seem similar to me (and I couldn’t find any information online via google search). Please provide example cases!
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In terms of data structures, you can think of embedded documents as hashes or dictionaries .. while arrays are a list of values.
With embedded documents in MongoDB:
With arrays in MongoDB:
$push,$pop,$pull, and$addToSet.$all,$in,$nin.$sliceoperator to retrieve a subset of an array.Mongoid’s notion of relations express a few different combinations of embedded documents and arrays: