Suppose I have this Mongoose Schema in my models.js file:
var Mongoose = require('mongoose');
var ProjectSchema = new Mongoose.Schema({
"name": String,
"id": String,
"phone": String,
"address": String,
"dob": String,
"action": String,
"ccard": {
"type": String,
"number": String,
"status": String,
"expiry": String
}
});
exports.Project = Mongoose.model('Project', ProjectSchema);
And suppose I already have website that uses MongoDB to load data from a JSON file with the necessary information. How would I call ccard's fields in a HTML template? As of now I'm able to call {{name}} and {{id}} in the {{each projects}} ... {{/each}} clause without issues, but when I call {{ccard.number}} it would not output anything.
HTML sample:
{{each projects}}
<table>
<tr>
<td>{{ccard.type}}</td>
<td>{{ccard.number}}</td>
<td>{{ccard.status}}</td>
<td>{{ccard.expiry}}</td>
</tr>
</table>
{{/each}}
Is the problem in the schema or the template variables or somewhere else?
{{ccard.type}}in your template?ccard's member variables, but none of the data in the JSON that corresponds to those variables appear when I run the site.digitsfield in ProjectSchema?numberbut I wrote it asdigits. I will correct it. I will add the HTML template code.