Another way to ensure perennial consistency is to future-proof your data structure. For instance, if we want to store a user's name, we could simply specify a name property of type string. This may work for now, but in the future, we may want to distinguish between first, middle, and last names. We may even want to implement sorting and filtering based on first or last names. Thinking even further ahead, many people, especially from Asian countries, have both an English and non-English name, and so we might even want to allow users to provide their names in multiple languages. Structuring your name property as a string wouldn't work!
This is why our user schema specifies an object as the data structure for the name property. This allows us to add more properties to the object without breaking existing code. For example, our profile object may eventually evolve into something like this:
{
name: {
first: "John",
middle: "Alan",
last: "Doe"
display: "John Doe",
nickname: "JD",
others: [{
lang: "zho",
name: "
"
}]
}
}