[英]Mongoose dynamic schema field
I need to develop a model using mogoose with a field that will hold my object attributes. 我需要使用mogoose开发一个模型,该模型将保存我的对象属性。 My problem is that these attributes are totaly changable, something like: 我的问题是这些属性是完全可变的,如:
StockItem1 : {
sku: 23492349,
class: 'computer',
subclass: 'printer',
name: 'Hp Laserjet XXX',
qty: 120,
attr: {
laser: true,
speed: 1200,
color: white
}
}
StockItem2 : {
sku: 22342349,
class: 'homeappliance',
subclass: 'refrigerator',
name: 'GE Refrigerator',
qty: 23,
attr: {
stainlessstell: true,
doors: 2,
frostfree: true
}
}
The attr
attributes fields are totally different depending of what type of class/subclass
it belongs to. attr
属性字段完全不同,具体取决于它所属的class/subclass
类型。
What type should be given to attr
field in mongoose ? 在猫鼬中应该给attr
字段什么类型? I need to filter those in the future, like get all itens where attr.doors == 2
. 我需要在将来过滤那些,比如在attr.doors == 2
得到所有的attr.doors == 2
。
Thanks for helping. 谢谢你的帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.