0
私はサイバーカフェ用のウェブサイトを作成しており、 "その特定のユーザ"が "その特定のコンピュータ"を使用していると指定する必要があります。アクティブなユーザとコンピュータのやりとり - MongoDB/Nodejs
var computerSchema = mongoose.Schema({
name: String,
type: String,
gpu: String,
cpu: String,
memory: String,
cm: String,
usedBy : {type: String, default: null},
active: {type: Boolean, default:false, ref:'user'}
});
var userSchema = mongoose.Schema({
firstname: String,
lastname: String,
age: Number,
address: String,
mail: String,
password: String,
status: String,
here: {type: Boolean, default:false},
created_date: Date,
updated_date: Date,
active_hash: String,
role_id: { type: Number, default: 2 }
});
userSchema.virtual('users', {
ref: 'computer',
localField:'_id',
foreignField:'active'
})