Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
name: {
type: String,
required: true,
trim: true,
},
balance: {
type: Number,
default: 0,
},
initialBalance: {
type: Number,
},
currency: {
type: String,
default: 'USD',
enum: currencyFormatter.currencies.map(currency => currency.code),
},
user: {
type: db.Schema.Types.ObjectId,
ref: 'User',
required: true,
},
}, {
toJSON: transformer,
toObject: transformer,
});
walletSchema.virtual('formattedBalance').get(function formatValue() {
return currencyValue(this.balance, this.currency);
});
walletSchema.pre('save', function preSave(next) {