Так что здесь дело. У меня есть две модели / схемы. и я хочу получить поле bid
в моей модели работы из модели предложения
Вот пример, когда я "POST" модель ставки с помощью почтальона:
{
"price": "8.770.000",
"negotiation": "this is just example",
"job" :"5c4192f5da1c3619f4089f5e" //this is job_id
}
и когда я пытаюсь «получить» модель работы, вот результат:
{
"id": "5c4192f5da1c3619f4089f5e",
"owner": {
"id": "5be541622a228a231c6769c2",
"username": "ceka",
"rating": 0,
},
"title": "create website",
"description": "this is just description",
"category": "programming",
"budget": "2.000.000",
"remote": true,
"bid": []
}
ставка пуста
заявка модель:
const bidderSchema = new Schema({
user: {
type: Schema.ObjectId,
ref: 'User',
required: true
},
job: {
type: Schema.ObjectId,
ref: "Job",
required: true
},
price: {
type: String
},
negotiation: {
type: String
}
}
и модель работы:
const jobSchema = new Schema({
owner: {
type: Schema.ObjectId,
ref: 'User',
required: true
},
title: {
type: String
},
description: {
type: String
},
bid: [
{
type: Schema.ObjectId,
ref: 'Bidder'
}
]
}
маршрутизатор:
export const index = ({ querymen: { query, select, cursor } }, res, next) =>
Job.find(query, select, cursor)
.populate('owner')
.then((jobs) => jobs.map((job) => job.view()))
.then(success(res))
.catch(next)
Итак, суть в том, что я хочу получить ставку из модели предложения на вакансию с помощью 'job_id', как я могу это сделать? Возможно ли это?