0

我正在尝试创建用于向现有用户添加地址的 API 路由

用户模式

 const userSchema = new mongoose.Schema({
        name  : type: String,
        email : type : String,
        password: type: String,
        address : [{type: mongoose.Schema.Types.ObjectId, ref: "Address"}],
    });
module.exports = mongoose.model('User', userSchema);

地址模式

addressSchema = new mongoose.Schema({
    name  : type: String,
    phone_number : type : Number,
    address1: type: String,
    address2: type: String,
    landmark: type: String,
    coordinates: [Number],
    created_at: { type: Date, default: Date.now()}
});

module.exports = mongoose.model('Address', addressSchema);

如何向现有用户添加新地址?

4

0 回答 0