Always wondering about constraints, relationships, entity/data reusablity and things like calculations, aggregations, ...; typical "SQL tasks" - how does one handle these in a document-oriented schemaless database like mongodb?
Whether you enforce password complexity in the database is a question of where your team is more comfortable working, and what the business requirements are.
You can enforce complex constrains like this in `>3.0`:
db.createCollection( "contacts",
{ validator: { $or:
[
{ phone: { $type: "string" } },
{ email: { $regex: /@mongodb\.com$/ } },
{ status: { $in: [ "Unknown", "Incomplete" ] } }
]
}
} )
While still not having to define the rest of the schema that you don't want too. It feels more flexible.I couldn't make a universal statement about where the constraints you're talking about should go without knowing the business rules for the application.
However, by constraints I was more talking about things like "these properties need to be unique", "this column here must reference that column over there", "this column's values must be in this set" and so on.
I know I could enforce these things in the application layer, but I don't think that's feasible.
Edit: Typo