0

I use mongodb as database and mongoose as ODM, and express(nodejs) as backend. So, I find item as:

const foundItem = await ItemModel.findOne({_id: 344363434643}).select(
      'name age'
);

after I clone the foundItem as:

const clonedFoundItem = {...foundItem}

But when I return it on frontend:

  res.send({
      data: clonedFoundItem
    });

I get some additional properties that not present in original object.

$__: {strictMode: true, selected: {…}, getters: {…}, _id: "344363434643", wasPopulated: false, …}
$init: true
$locals: {}
$op: null
isNew: false
_doc: {_id: "344363434643", name: 'Jim', age: '12'}

And they not presented on backend.

How I can get rid of its?

Gregory Kafanov
  • 339
  • 1
  • 3
  • 11

0 Answers0