MongoDB中相似模糊查询操作
发布时间:2023-10-16 15:54:33 所属栏目:系统 来源:
导读:MongoDB中类似模糊查询操作
1.查看集合
show collections
2.向集合中添加数据
db.runoob.insertMany([
{
'title':'data1',
'url':'https://blog.51cto.com
1.查看集合
show collections
2.向集合中添加数据
db.runoob.insertMany([
{
'title':'data1',
'url':'https://blog.51cto.com
MongoDB中类似模糊查询操作 1.查看集合 show collections 2.向集合中添加数据 db.runoob.insertMany([ { 'title':'data1', 'url':'https://blog.51cto.com/suyanzhu', 'description':'this is data1', 'view':5000 }, { 'title':'data2', 'url':'https://blog.51cto.com/suyanzhu', 'description':'this is data2', 'view':3650 }, { 'title':'data3', 'url':'https://blog.51cto.com/suyanzhu', 'description':'this is data3', 'view':9527 } ]) 3.查看所有数据 db.runoob.find().pretty() 4.查询包含指定字符串的数据 // title中包含a1字符串的数据 db.runoob.find({'title':/a1/}).pretty() 5.查询以指定字符串开头的数据 // title以d开头的数据 db.runoob.find({'title':/^d/}).pretty() 6.查询以指定字符串结尾的数据 // title以a3结尾的数据 db.runoob.find({'title':/a3$/}).pretty() (编辑:聊城站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐