lrf 2 years ago
parent
commit
8ac0602e3a
1 changed files with 14 additions and 12 deletions
  1. 14 12
      lib/model/type-money-plugin.js

+ 14 - 12
lib/model/type-money-plugin.js

@@ -1,15 +1,17 @@
 'use strict';
 const { Decimal128 } = require('mongoose').Types;
-module.exports = exports = function metaPlugin(schema /* , options*/) {
-  schema.add({
-    money: {
-      type: Decimal128,
-      set(data) {
-        return data;
+module.exports = exports = params =>
+  function metaPlugin(schema /* , options*/) {
+    schema.add({
+      money: {
+        type: Decimal128,
+        set(data) {
+          return data;
+        },
+        get(data) {
+          if (data) return data.toString() * 1;
+        },
+        ...params,
       },
-      get(data) {
-        if (data) return data.toString() * 1;
-      },
-    },
-  });
-};
+    });
+  };