angular-bridge
angular-bridge copied to clipboard
Nested resouces
Can we see an example using nested resources, I can't seem to figure out how that would work. I have a mongoose Schema like so:
var mongoose = require('mongoose');
module.exports = function Schemas() {
this.schema = mongoose.Schema;
this.EmployeeSchema = new this.schema({
'firstname': {
type: String,
required: true,
trim: true
},
'lastname': {
type: String,
required: true,
trim: true
},
'email': {
type: String,
required: true,
trim: true,
index: true,
validate: /\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}\b/
},
'departmentId': {
type: this.schema.ObjectId,
trim: true,
required: true
},
'enddate': {
type: String,
trim: true
},
'active': {
type: Boolean,
"default": true
}
});
this.EmployeeSchemaModel = mongoose.model('employees', this.EmployeeSchema);
this.DepartmentSchema = new this.schema({
'name': {
type: String,
required: true,
trim: true,
index: {
unique: true
}
},
'employees': [this.EmployeeSchema]
});
this.DepartmentSchemaModel = mongoose.model('departments', this.DepartmentSchema);
mongoose.connect('mongodb://localhost:8120/staff');
};
So I have Employee
documents nested within Departments
. How do I configure angular-bridge to give me URL's like:
/departments/{some department id}/employees/{some employee id}
For now anglar-bridge doesn't handle nested resources, but it's a very interesting feature. Feel free to contribute !
Thanks
Ok, thanks for replying. Just wanted to make sure I wasn't missing anything.
+1 - My Express knowledge isn't up to the task at the moment, but nested resources would be excellent!