Skip to main content

馃憪 Clean book attributes up

We want to clean up the book_attributes array in our MongoDB schema. We want an array of objects containing attributes, modelled a key value pairs. something like:

{
"_id": 838383, // book id
"attributes": [
{
"key": "price",
"value": 11
},
{
"key": "pages",
"value": 236
},
// ...
]
}
  • On the MongoDB diagram view, click the books collection
  • On the relational mappings list on the right, click on the edit icon of book_attribute embedded array mapping rule.
  • Change the Field name from bookAttributes to attributes
  • Uncheck bookId. We just want all the attributes, which are key/value pairs.
  • Click Save and close
info

Here we've implemented the Attribute Pattern for MongoDB. This will allow for easy indexing, querying based on attributes and extension of attributes.

Screenshot of the connect modal