function buildPreSavePromise(document, options) {
  return new Promise((resolve, reject) => {
    document.schema.s.hooks.execPre('save', document, [options], (err) => {
      if (err) {
        reject(err);
        return;
      }
      resolve();
    });
  });
}
Takes an array of documents, gets the changes and inserts/updates documents in the database
according to whether or not the document is new, or whether it has changes or not.

`bulkSave` uses `bulkWrite` under the hood, so it's mostly useful when dealing with many documents (10K+)

`bulkSave()` throws errors under the following conditions:

- one of the provided documents fails validation. In this case, `bulkSave()` does not send a `bulkWrite()`, and throws the first validation error.
- `bulkWrite()` fails (for example, due to being unable to connect to MongoDB or due to duplicate key error)
- `bulkWrite()` did not insert or update **any** documents. In this case, `bulkSave()` will throw a DocumentNotFound error.

Note that `bulkSave()` will **not** throw an error if only some of the `save()` calls succeeded.

@param {Array<Document>} documents
@param {Object} [options] options passed to the underlying `bulkWrite()`
@param {Boolean} [options.timestamps] defaults to `null`, when set to false, mongoose will not add/update timestamps to the documents.
@param {ClientSession} [options.session=null] The session associated with this bulk write. See [transactions docs](https://mongoosejs.com/docs/transactions.html).
@param {String|number} [options.w=1] The [write concern](https://www.mongodb.com/docs/manual/reference/write-concern/). See [`Query#w()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.w()) for more information.
@param {number} [options.wtimeout=null] The [write concern timeout](https://www.mongodb.com/docs/manual/reference/write-concern/#wtimeout).
@param {Boolean} [options.j=true] If false, disable [journal acknowledgement](https://www.mongodb.com/docs/manual/reference/write-concern/#j-option)
@param {Boolean} [options.validateBeforeSave=true] set to `false` to skip Mongoose validation on all documents
@return {BulkWriteResult} the return value from `bulkWrite()`