applyWriteConcern.js 472 B

12345678910111213141516
  1. 'use strict';
  2. const get = require('../get');
  3. module.exports = function applyWriteConcern(schema, options) {
  4. const writeConcern = get(schema, 'options.writeConcern', {});
  5. if (!('w' in options) && writeConcern.w != null) {
  6. options.w = writeConcern.w;
  7. }
  8. if (!('j' in options) && writeConcern.j != null) {
  9. options.j = writeConcern.j;
  10. }
  11. if (!('wtimeout' in options) && writeConcern.wtimeout != null) {
  12. options.wtimeout = writeConcern.wtimeout;
  13. }
  14. };