Информация из mongodb не выводится в элемент pug
В схеме базы данных есть ключ Biography, его то нам и надо вывести в модальное окно документа PUG. В PUG ничего не выводится.
Вот схема:
const characterSchema = new Schema({
desc: String,
tag: String,
info: String,
creator: String,
state: Object,
account: {
type: Schema.Types.ObjectId,
index: true,
ref: 'Account'
},
site: {
type: Schema.Types.ObjectId,
ref: 'Auth'
},
name: {
type: String,
index: true
},
flags: {
type: Number,
default: 0
},
lastUsed: {
type: Date,
index: true
},
biography: {
type: String,
index: true
},
}, { timestamps: true });
Вот модель:
export const Character = model<ICharacter>('Character', characterSchema);
Функция запроса id пользователя:
export async function exportBiography(res:any, accountId: ID){
const modalb = await Character.findById(accountId);
res.render('index', { modalb: JSON.stringify(modalb) });
}
Обращение к функции в конструкции switch (фрагмент):
case PlayerAction.ShowModal:
app.get(this.client.accountId, (req: any, res: any) => {
exportBiography(res, req.parrams.id);
});
Непосредственно модальное окно в PUG, куда и нужно вывести наш ключ (попытка вывести нужные данные в .modal-content):
.modal-overlay
.modal
a.close-modal
svg(viewbox='0 0 20 20')
path(fill='#000000' d='M15.898,4.045c-0.271-0.272-0.713-0.272-0.986,0l-4.71,4.711L5.493,4.045c-0.272-0.272-0.714-0.272-0.986,0s-0.272,0.714,0,0.986l4.709,4.711l-4.71,4.711c-0.272,0.271-0.272,0.713,0,0.986c0.136,0.136,0.314,0.203,0.492,0.203c0.179,0,0.357-0.067,0.493-0.203l4.711-4.711l4.71,4.711c0.137,0.136,0.314,0.203,0.494,0.203c0.178,0,0.355-0.067,0.492-0.203c0.273-0.273,0.273-0.715,0-0.986l-4.711-4.711l4.711-4.711C16.172,4.759,16.172,4.317,15.898,4.045z')
// close modal
.modal-content
| {{modalb.biography}}