I have an event object which is fetched from MongoDB via Mongoose plug in. Have done some of the operation in this object and finally I want to save this object in another collection with same structure.
For this I need to delete all properties starts from '_' or '__' like '_id' and '__v'. I have written code like:
console.log(event);
console.log(delete event._id);
console.log(event);
Line 1 and 3 prints same value with _id property. Same thing works fine if I delete some other property like 'code'. here is complete event object:
{ _id: 5a51019b211d740a174a1fba,
__t: 'EventModel',
code: '02',
event: 'testMe',
source: 'user',
target: 'cronjob',
__v: 0,
params:
[ { key: 'Nodics',
value: 'Framework',
_id: 5a51019b211d740a174a1fbb } ],
log: [ 'Published Successfully' ],
hits: 1,
type: 'ASYNC',
state: 'FINISHED',
testProperty: 'Nodics Framework',
updatedDate: 2018-01-13T17:04:15.288Z,
creationDate: 2018-01-13T17:04:15.288Z
}
Please help me out to understand root cause and how I can deal with this. for me it looks direct or inherited properties issue. but required experts comments.