我有一个看起来像这样的架构:
"use strict"
const mongoose = require('mongoose');
const timestamp = require('mongoose-timestamp');
const CustomerSchema = new mongoose.Schema({
name : {
type : String,
required : true,
trim : true
},
email : {
type : String,
required : true,
trim : true
},
balance : {
type : Number ,
default : 0
}
})
//use timestamps to add created at and updated at
CustomerSchema.plugin(timestamp);
const Customer = mongoose.model('Customer',CustomerSchema);
module.exports = Customer;
Run Code Online (Sandbox Code Playgroud)
当我想运行更新时,我运行此代码
const Customer = require('../models/Customer');
const customer = await …Run Code Online (Sandbox Code Playgroud)