Mongoose The difference between save() / update() / findoneandupdate()


Advertising mongoose Chinese document translation recruitment…

. save() and update()

  • Update is more efficient than save () after find, because it doesn’t need to read the whole document.
  • Mongoose update is mongodb update, but mongoose save may be mongodb insert or update.
  • As for save, mongoose will automatically diff the new document and only change the updated part. This is conducive to atomicity.
  • Update cannot trigger middleware. Validation cannot be triggered by default, but can be modified.

Update() and findoneandupdate()

  • Update() returns the number of data processing entries
  • Findoneandupdate() returns the processed data
  • In short, if you need to obtain data, use findoneandupdate(). If you only need to modify the data without paying attention to the modified data, use update().

Reference articles………

Recommended Today

Python actual combat case, pywifi module, python brutally crack WiFi password of nearby LAN

preface Today, I’ll show you Python script to decipher WiFi password. Without much nonsense, let’s start directly~ development tool Python version: 3.6.4 Related modules: Pywifi module; Datetime module; And some Python’s own modules. Environment construction Install Python and add it to the environment variable. PIP can install the relevant modules required. WiFi decoding source code […]