I have two models:
const walletSchema = mongoose.Schema({
title: { type: String, required: true },
description: { type: String, required: false},
amountStart: { type: Number, required: true},
mount: {type: Number, required: false},
transfers: [{ type: Schema.Types.ObjectId, ref:'Transfers' }],
});
and
const transferSchema = mongoose.Schema({
mount: { type: Number, required: true },
category_id: { type: Schema.ObjectId, ref: "Category", required: false },
description: { type: String, required: false},
wallet_id: { type: mongoose.Schema.Types.ObjectId, ref:"Wallet", required: true}
});
and I want get the mount of the wallet (amountStart - all mount of transfers)
but I'm not sure how to do it, thanks!