Typebased References with Arrays
Supose the following case (schemas), where a company holds the reference of the owner, which is an entrepreneur.
Entrepreneur.js
{
niceName: String,
birth: Date,
}
Company.js
{
niceName: String,
owner: {type: ObjectId, ref: 'Entrepreneur'},
employees: Number
}
The typebased generation will produce three new endpoints that will be like the followings:
- GET /company/:company_id/owner
Result:
{ niceName: String, birth: Date }
- GET /user/:user_id/companies/owner
Result:
{ "status": { "count": # Number of total in database, "search_count": # Number in this result }, "result": [ { niceName: String, owner: {type: ObjectId, ref: 'Entrepreneur'}, employees: Number } ] }
- POST /user/:user_id/companies/owner
Query:
{ }
Result:
{ "status": { "count": # Number of total in database, "search_count": # Number in this result }, "result": [ { niceName: String, owner: {type: ObjectId, ref: 'Entrepreneur'}, employees: Number } ] }