我有一个架构,该架构具有另一个架构的objectid的数组。
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form id="form1">
<label>Name</label>
<input name="name">
<label>
<input type="checkbox" name="accepts_tou">
Do you accept out Terms of use?
</label>
</form>
<form id="form2">
<label>Name</label>
<input name="name">
<label>
<input type="checkbox" name="accepts_tou">
Do you accept out Terms of use?
</label>
</form>
<button>Compare</button>
const mongoose = require('mongoose');
const Suiteschema = new mongoose.Schema({
identifier: {
type: String,
required: true
},
user: {
type: String,
required: true
},
channel: {
type: String,
required: true
},
cases: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Case' }],
server: [{ type: String, required: false}],
browser: {
type: String,
required: false,
default: 'chrome'
},
location: {
type: String,
required: false,
default: 'local'
},
timeout: {
type: String,
required: false,
default: '0'
},
uptimeout: {
type: String,
required: false,
default: '0'
},
type: {
type: String,
required: false,
default: 'cl'
},
last: {
type: Date,
default: Date.now
},
created: {
type: Date,
default: Date.now
}
});
const Suite = mongoose.model('Cafesuites', Suiteschema);
module.exports = Suite;
现在我用以下方法查询套件模式:
const mongoose = require('mongoose');
const CaseSchema = new mongoose.Schema({
szenario: {
type: String,
default: 'deprecated'
},
use: {
type: String,
default: 'true'
},
description: {
type: String,
required: true
},
data: {
type: String,
required: true
},
xml: {
type: String,
required: false
},
path: {
type: String,
required: false
},
type: {
type: String,
required: false
},
date: {
type: Date,
default: Date.now
}
});
const Case = mongoose.model('Cafescripts', CaseSchema);
module.exports = Case;
结果是我得到了一个objectids数组
var thecase = await Suite.findById(id).exec();
现在我的核心问题是,猫鼬中是否有一种方法可以直接获取案件描述而不是对象ID?以我的理解,因为它是对模式“ Case”的引用,所以这是可能的。但是如何?