第一次使用mongodb。我在服务器端使用 node.js 和 mongojs。有点困惑。db.save 的反转是 find,我希望能够做类似的事情:
db.furni.find( db.furni_types.chair, db.furni_types.chair.plastic );
当前设置:
// Chair types
db.furni_types.save({ type: "chair", material: "wood" });
db.furni_types.save({ type: "chair", material: "plastic" });
db.furni_types.save({ type: "chair", material: "beanbag" });
// other furni types
db.furni_types.save({ type: "bed", material: "silk" });
db.furni_types.save({ type: "table", effect: "glass" });
db.furni.save({id: "13626450", name: "ComfyMan", type: "chair", material: "wood", description: "The most comfortable chair in extistence."});
几个问题:
我是以正确的方式解决这个问题还是什么?
如果我以后想将它们用作对象,在 db.furni.save(type: "chair", material: "wood") 中找到的数组是否足够?
如果我想做类似的事情怎么办:
db.furni.save( name: "Super Comfort", db.furni_types.chair, db.furni_types.chair.wood );
上面的方法有用吗?