草庐IT

collection_items

全部标签

mongodb - PyMongo 文档中的 "sub-collection"是什么意思?

Thispageinthedocumentation说你可以使用c[name]或c.name访问集合,其中c是一个集合,但子集合到底是什么意思?我在mongodb文档中找不到该术语的任何用法。我假设的是,它获取集合中每个文档的键name的值,并将其表示为自己的集合。是这样吗? 最佳答案 Asubcollection只是在集合名称中使用.作为组织集合名称的一种命名约定。所以用下面的代码:client=pymongo.MongoClient()db=client['mydb']coll=db['test']subcoll=coll['s

mongodb - 项目 : {$exists:false} and item : null? 之间有什么区别

这样做有什么区别:"AnArray.fieldA":null和"AnArray.fieldA":{$exists:false}为什么在这样的文件上{AnArray:[{},{fieldA:1}]},{AnArray:[{fieldA:3},{fieldA:1}]}"AnArray.fieldA":null给我返回第一个文档,但是"AnArray.fieldA":{$exists:false}返回给我没有文档:( 最佳答案 很好地解释了here.The{item:null}querymatchesdocumentsthateither

javascript - meteor JS : resubscribe/refresh a Collection?

我目前正在处理我的meteor项目,但我不太了解解决我的问题的meteor方式是什么。我有一个最初在页面加载时调用的订阅。我在没有任何参数的情况下订阅了以下出版物:Meteor.publish('testCollection',function(searchitem){if(searchitem){returntestCollection.find({name:searchitem});}else{returntestCollection.find({},{sort:{rating:-1},limit:5,fields:{_id:1,name:1,description:1}});}}

node.js - 将查询条件传递给生成查询字符串的 Node.js/Mongodb 中的 db.collection.find

我正在尝试构建一个NodeJS/mongodb应用程序,当我读取一个包含(XYZ>10)的请求时或者(XYZ.我想在旅途中生成一个查询字符串。然后在某个Mongodb集合中进行搜索。以下将起作用:db.event.find({'data.XYZ':{'$lt':15}})//Thisworks.但我想这样做:varqstr1="{\'data.XYZ\':{\'$lt\':15}//Iwouldgeneratethispossiblydb.event.find(qstr1)当我尝试将查询条件作为字符串传递给db.collection.find()时它返回给我整个集合。我正在使用mong

c# - 执行 Mongo 查询 db.collection.runCommand ("text", {"search":"search text"})

我需要在我的站点、mongodb数据库中添加全文搜索选项,蒙戈查询:db.collection.runCommand("text",{"search":"searchtext"})给出结果,但如何使用C#执行它? 最佳答案 _collection.Insert(newBsonDocument("x","Thequickbrownfox"));vartextSearchCommand=newCommandDocument{{"text",_collection.Name},{"search","fox"}};varcommandRes

mongodb - 来自 Collection 的 Meteor .find() 返回 [object Object]

在Ubuntu上运行Data.js//CollectionsDatabase=newMeteor.Collection('data');if(Meteor.isClient){Template.main.data=function(){varc=Database.find();returnc;};}if(Meteor.isServer){Meteor.startup(function(){//codetorunonserveratstartup});}data.htmldata{{>main}}{{data}}我使用mongo插入数据库:>db.Database.insert({tit

mongodb - db.collection 不是函数?什么?

我正在学习mongodb并遵循以下代码的教程:Myindex.jsfile:varMongoClient=require('mongodb').MongoClient;varurl='mongodb://u****:p****@ds131687.mlab.com:31687/learning_mongo';varfindDocuments=function(db,callback){varcollection=db.collection('tours');collection.find().toArray(function(err,docs){if(err)throwerr;conso

mongodb - Meteor Collection.find 在动态 mongo 查询中使用变量作为字段

我试图在Collection.find查询中使用变量作为字段说明符,但tit只是忽略了它varqry="{\""+field_name+"\":"+field_value+"}"console.log(qry)//{"customer_active":true}Customers.find(qry).map(function(customer){//doesn'tfindanythingconsole.log(customer)vargroups=customer.customer_group_id.push(a._id)Customers.update({$set:{customer

ruby-on-rails - MongoDB/Mongoid : search for documents matching first item in array

我有一个包含数组的文档:{_id:ObjectId("515e10784903724d72000003"),association_chain:[{name:"Product",id:ObjectId("4e1e2cdd9a86652647000003")}],//...}我正在尝试在集合中搜索association_chain数组中第一项的name与给定值匹配的文档。我如何使用Mongoid执行此操作?或者,如果您只知道如何使用MongoDB完成此操作,如果您发布一个示例,那么我可能会弄清楚如何使用Mongoid完成此操作。 最佳答案

node.js - 'db.collection' 与 'new mongo.Collection' 之间的区别

在方法1和方法2之间是否有任何区别(除了方法1是异步的)以获取对如下所示的mongodb集合的引用?varmongo=require('mongodb');vardb=newmongo.Db('blog',newmongo.Server(host,port,{auto_reconnect:true},{}));db.open(function(){//Method1db.collection('articles',function(err,result){varcollection1=result;});//Method2varcollection2=newmongo.Collecti