С приведенной ниже схемой я пытаюсь найти с выбранными полями. В результате я получаю только первые 2 org_name и описание, но другие не получают. Есть идеи. Я новичок в пн goose. Я не могу найти причину из документации тоже. Любая помощь будет оценена.
Моя схема:
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
let JobsSchema = new Schema ({
_id: {type:String, required: true, max:100},
sector: {type:String, required: true, max:100},
category: {type:String, required: true, max:100},
apply_mode: {type:String, required: true, max:100},
org_name: {type:String, required: true, max:100},
description: {type:String, required: true},
start_date: {type: Date},
end_date: {type: Date},
total_openings: {type: Number},
total_openings_description: {type:String},
min_salary: {type: Number},
max_salary: {type: Number},
salary_description: {type: String},
apply_steps: {type: String},
tags: [],
additional_dates: [{
additional_date_label: {type:String, required: true, max:100},
additional_date_value: {type:Date},
}],
age_limits: [{
age_limit_label: {type:String, required: true, max:100},
age_limit_min_value: {type: Number},
age_limit_max_value: {type: Number},
}],
application_fees: [{
application_fee_label: {type:String, required: true, max:100},
application_fee_value: {type: Number},
}],
url_links: [{
url_link_label: {type:String, required: true, max:100},
url_link_value: {type:String, required: true, max:100},
}]
},
{ collection: 'Jobs' }); // this line to match name in db
module.exports = mongoose.model('jobs', JobsSchema);
Мой запрос:
Job.find(
{},
"org_name description start_date end_date total_openings min_salary max_salary",
{ sort: { start_date: "asc" }, skip: pageNumber * pageSize, limit: pageSize },
(err, jobs) => {
if (err) {
res.render("error", {
errMsg: "issue in getting records. Try after sometime.",
errBody: err
});
}
if (jobs) {
res.render("listJob", {
jobs: jobs
});
}
}
);
Результат
[
{
"_id": "Job1",
"org_name": "Test org",
"description": "<p>Test Desc</p><p><b>Hello world</b></p>"
},
{
"_id": "Job2",
"org_name": "Test org11",
"description": "<p>Test descr</p>"
},
{
"_id": "Job10",
"org_name": "Test inc 1",
"description": "<p>,smdfndfskj</p>"
}
]