首页 > 学院 > 开发设计 > 正文

mongodb操作集合

2019-11-08 21:00:40
字体:
来源:转载
供稿:网友

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}});


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表