Browse Source

修改金额插件

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

+ 2 - 2
lib/model/type-money-plugin.js

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