0

I have been looking through all the questions but eventhough it should be something common, I did not see any question like that. So, I have a data in my db like that, I would like to delete only token field after a specific timeout in nodejs. I thought using deleteOne method but it deletes the whole data. I need to keep the data other than the token. Thanks

{
 "_id": "samplesample",
 "item":{},
 "password": "$2a$10$vsB.X7OZIv1464PX38wj2OZ9it7lxCtToM4CxQx8MANy1GzluTEmy",
 "token": "b166VSe1vdpUMe9S"
}
Ugur Yilmaz
  • 469
  • 6
  • 17
  • Use [`$unset`](https://docs.mongodb.com/manual/reference/operator/update/unset/) and write your own scheduling code. There is no "built-in" scheduler aside from the handling of TTL indexes, which is "document removal" and indeed not this. – Neil Lunn Nov 04 '17 at 22:06
  • Thanks, I don't know how did not I see that. I 'll take a look! – Ugur Yilmaz Nov 04 '17 at 22:08
  • Probably a good idea when you need to know something to try searching for it first https://www.google.com/q=mongodb+remove+field since the top results are basically what you just got pointed to. – Neil Lunn Nov 04 '17 at 22:10

0 Answers0