How can I specify a composite type for a mongoose field? The task is as follows: there are two documents "Income" and "Expense" and when they are written to the database, you must also make an entry in the table with cash flows, and in this table there will be a "doc" field in which there can be both an arrival and an expense. How to do it. Now I did it like this, doc: {id: String, ref: String}, in doc I save the document id and view, but something seems to me that this is not correct:
var mongoose = require('mongoose'); var schema = new mongoose.Schema({ kind: String, date: Date, doc: { id: String, ref: String }, purse: { type: mongoose.Schema.Types.ObjectId, ref: 'Purse' }, article: { id: String, ref: String, name: String }, sum: Number }); module.exports = mongoose.model('FlowOfFund', schema);