у меня есть 2 схемы:Mongoose: найти все ссылки документы
var pollSchema = new mongoose.Schema({
title: String,
created: {
type: Date, default: Date.now
},
options: [{
label: String,
count: {
type: Number, default: 0
},
backgroundColor: {
type: String, default: '#fff'
}
}],
author:{
id:{
type: mongoose.Schema.Types.ObjectId,
ref: "User"
},
username: String
}
});
var userSchema = new Schema({
username: {type: String, unique:true},
email: {type: String, unique:true, lowercase: true},
password: String
});
Теперь каждый опрос будет хранить данные из его автора. Вопросы:
- Как я могу перестроить свои схемы - так я смогу найти все опросы принадлежат конкретному пользователю?
- Или я должен оставить схемы одинаковыми и найти другой подход?