so, i have a Mongoose Schema, something like:
Person: {
name: String,
address: {
street: String,
number: String,
city: String
}
}
Is there a way, to code our form so that i can map directly from req.body to the Person instance? considering the sub-division in address. I tried:
<form>
<input name="name">
<input name="address.street">
<input name="address.number">
<input name="address.city">
</form>
and it doesn't work...
Try this:
<form>
<input name="name">
<input name="address[street]">
<input name="address[number]">
<input name="address[city]">
</form>
See this post on application/x-www-form-urlencoded encoding.