我想搜索所有存在的值,而无需显式指定键。这种类型的模式可能吗?如果是这样,我该如何编写查询。我试图用其他引用编写查询,但是如果不为每个引用指定键,就无法编写查询。
const pschema = new Schema({
user: {
type: Schema.Types.ObjectId, // combine by id
ref: "users" //existing model reference
},
company: {
empNo: {
type: Number,
required: true
},
status: {
type: String,
required: true
},...
},
personal: {
gender: {
type: String
},
dob: {
type: Date
},...
},
skills: {
type: [String],
required: true
},
experience: [
{
title: {
type: String,
required: true
},
company: {
type: String,
required: true
},
location: {
type: String
}...
}
],
education: [
{
school: {
type: String,
required: true
},
degree: {
type: String,
required: true
},
specialization: {
type: String
},..
}
],
social: {
twitter: {
type: String
},
facebook: {
type: String
},
linkedin: {
type: String
},...
}
});
例如:如果我给linkedin网址提供搜索,则应该在社交linkedin中搜索;如果我给c,则应该输入技能数组中的搜索