attachmentFiles.chunks.js 876 B

1234567891011121314151617181920212223242526272829303132
  1. const { Binary } = require('mongodb');
  2. const { ObjectId } = require('mongoose').Types;
  3. class AttachmentFilesChunksOverwriteParamsFactory {
  4. /**
  5. * generate overwrite params object
  6. * @param {string} operatorUserId
  7. * @param {ImportOptionForPages} option
  8. * @return object
  9. * key: property name
  10. * value: any value or a function `(value, { document, schema, propertyName }) => { return newValue }`
  11. */
  12. static generate(operatorUserId, option) {
  13. const params = {};
  14. // Date
  15. params.files_id = (value, { document, schema, propertyName }) => {
  16. return ObjectId(value);
  17. };
  18. // Binary
  19. params.data = (value, { document, schema, propertyName }) => {
  20. return Binary(value);
  21. };
  22. return params;
  23. }
  24. }
  25. module.exports = (operatorUserId, option) => AttachmentFilesChunksOverwriteParamsFactory.generate(operatorUserId, option);