MongoDB实验——数据库基本操作
文档操作二
#********* Begin *********#
echo "
document=([
{_id:1,
name:'西西',
sex:'女',
age:23,
national:'汉族',
},
{_id:2,
name:'东东',
sex:'男',
age:20,
national:'苗族',
},
{_id:3,
name:'北北',
sex:'男',
age:19,
national:'汉族',
},
{_id:4,
name:'南南',
sex:'女',
age:15,
national:'傣族',
},
]);
db.stu1.insert(document);
db.stu2.insert(document);
db.stu1.find({'sex':'女','age':{\$gte:15}}).pretty();
db.stu1.find({'national':'苗族'}).pretty();
db.stu1.find({'sex':'男','age':{\$lt:20}}).pretty();