Я получаю сообщение об ошибке при попытке сохранить следующие данные.
Ниже приведена ошибка:
if (fields [key]. $ ElemMatch) {
^
TypeError: Невозможно прочитать свойство '$ elemMatch' из неопределенного
at model.Query._castFields (C: \ Users \ hp \ Documents \ node-projects \ musicfest1 \ node_modules \ mongoose \ lib \ query.js: 4306: 23)
на модель. Запрос. (C: \ Users \ л \ Documents \ узел-проектов \ musicfest1 \ node_modules \ мангуст \ Lib \ query.js: 1971: 23)
в model.Query._wrappedThunk [as _findOne] (C: \ Users \ hp \ Documents \ node-projects \ musicfest1 \ node_modules \ mongoose \ lib \ helpers \ query \ wrapThunk.js: 16: 8)
at process.nextTick (C: \ Users \ hp \ Documents \ node-projects \ musicfest1 \ node_modules \ kareem \ index.js: 369: 33)
at process.internalTickCallback (internal / process / next_tick.js: 70: 11)
var data = {
eventid: 'eventezy01',
eventname: event_name,
title1: title1,
title2: title2,
dateVenue: dateVenue,
date: date,
venue: venue,
hsTicket: hsTicket,
ticketLink: ticketLink,
ticketPrice: ticketPrice,
about_heading: about_heading,
aboutEvent1: aboutEvent1,
singer_heading: singer_heading,
hsSinger: hsSinger,
sponsor_heading: sponsor_heading,
hsSponsor: hsSponsor,
singer: arrSinger,
sponsors: arrSponsor,
flocation: flocation,
femail: femail,
fcontact: fcontact,
fbLink: fbLink,
twitterLink: twitterLink,
youTubeLink: youTubeLink,
gPlusLink: gPlusLink,
instaLink: instaLink,
color: '#f50136',
bgImage: 'slider.png',
font: '"Montserrat", sans-serif'
};
FestData.findOne({eventid: 'eventezy01'}, data, options, (err, doc) => {
if(err) {
console.log(err);
}
if(!doc) {
var festData = new FestData(data);
festData.save();
}