草庐IT

some_collection

全部标签

node.js - Mongoose:通过 Model.collection.insert 批量插入会使 Node.js 崩溃并出现段错误 11

我有10,000,000个文档要插入到MongoDB中。我使用mongoose来创建解析后的JSON的文档(JSON是通过大量txt文件的内容转换创建的)。我开始为每个文档使用Model.create,但速度很慢,需要几天才能完成操作。所以我切换到Model.collection.insert来加快速度。这是我的saveToDB函数(用TypeScript编写):privatesaveToDB(hand:Hand):void{this.bulkHands.push(newHandHistory(hand));if(this.bulkHands.length>=10000){HandHi

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

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

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

node.js - 如何在 MongoDB collection.find() 上获得回调

当我在MongoDB/Node/Express中运行collection.find()时,我想在它完成时得到一个回调。正确的语法是什么?function(id,callback){varo_id=newBSON.ObjectID(id);db.open(function(err,db){db.collection('users',function(err,collection){collection.find({'_id':o_id},function(err,results){//What'sthecorrectcallbacksynataxhere?db.close();callb