mongodb操作集合

来源:互联网 发布:手机淘宝如何降价提醒 编辑:程序博客网 时间:2024/05/16 11:20

1 数据库操作

  1 切换或创建数据库

use yourDB; 

2 删除数据库

db.dropDatabase();

2 Collection聚集集合

1 创建集合

db.createCollection(“collName”);


3 集合查询

1 查询所有记录

db.userInfo.find();
2 查询age = 22的记录
db.userInfo.find({"age": 22});

3 查询age>22的记录

db.userInfo.find({age: {$gt: 22}});

4查询age<22的记录

db.userInfo.find({age: {$lt: 22}});

5查询age>=25的记录

db.userInfo.find({age: {$gte: 25}});



0 0
原创粉丝点击