我在我的 node.js 应用程序中使用猫鼬,基本上有以下模型:
// Define Car model
CarSchema = new Schema({
brand : String,
type: String,
maxSpeed : Number
});
mongoose.model('Car', CarSchema);
// Define User model
UserSchema = new Schema({
lastname : String,
firstname : String,
cars : [CarSchema]
});
mongoose.model('User', UserSchema);
我对 NoSQL 真的很陌生,我真的很想尝试一下,但我首先需要研究这是否真的符合我的需求。
使用上述模型,我是否能够创建一个查询,列出所有在其私人汽车中拥有特定类型汽车的用户?