草庐IT

DB_DRIVER

全部标签

javascript - MongoDb 在 db.close() 上抛出错误

这个问题在这里已经有了答案:HowdoIreturntheresponsefromanasynchronouscall?(44个答案)关闭7年前。我正在使用以下代码将文档保存到数据库:MongoClient.connect(mongoUrl,function(error,db){console.log('Mongo:error=\''+error+'\'db=\''+db+'\'');insertDocument(db,parsedDocument);db.close();});functioninsertDocument(db,document){db.collection('tes

c# - MongoDB 聚合 Shell 脚本到 MongoC# Driver

如何将此MongoShell脚本转换为MongoDBC#驱动程序?varmyItems=[]varmyCursor=db.Tickets.aggregate([{$match:{TicketProjectID:49}},{$project:{TicketProjectID:1,TicketID:1,concatValue:{$concat:["$Status","-","$Name"]}}}//IwillhavealistoffieldsthatIneedtoconcatenateatruntime.SoC#queryshouldsupportconcatenationfor"N"nu

node.js - 如何在nodejs中将变量名称作为mongo db的集合名称传递

我正在使用Nodejs和mongodb,我想将一个变量传递给集合varid="someid";db.collection(id).insert("somejsondata");如果我这样做,它会给我一个错误,因为集合名称必须是一个字符串。 最佳答案 您可以使用var作为集合名称创建变量varcolName="mytest"然后对集合执行如下所有操作:db[colName].find()db[colName].rename("newName")等这将帮助您保持集合名称动态,甚至可以更新它以保持您的命令不变。希望这对您有所帮助!

c# - 如何使用 C# MongoDB.Driver 更新深层嵌套数组?

我有这样的模型:{"_id":"5b90eea8c02e062be2888446","storeGuid":"e97d4730-9b8a-49ed-be87-caf4054439aa","storeId":"0","storeDbName":"0","tenant":"dev","configGroup":[{"groupName":"peopleCounter","config":[{"key":"averageWaitPeriodTime","value":"60",}]},{"groupName":"sessionMonitor","config":[{"key":"testKe

ruby - 如何使用 MongoDB Ruby Driver 做一个 "Group"(group by)?

与MongoDBGroupusingRubydriver有关如果我想在SQL中执行如下操作:selectpage_id,count(page_id)froma_tablegroupbypage_id我以为MongoDB的文档说http://api.mongodb.org/ruby/current/Mongo/Collection.html#group-instance_methodgroup(key,condition,initial,reduce,finalize=nil)#returnsanarray所以在另一篇文章中,我正在使用:Analytic.collection.group

node.js - MongoError : cannot establish topology capabilities as driver is still in process of connecting at Server. 功能

我正在尝试通过mongoose.connect连接到mongoDB,但我仍然收到错误:/Users/Documents/Business/01000100/node_modules/connect-mongo/lib/connect-mongo.js:133throwerr;^MongoError:cannotestablishtopologycapabilitiesasdriverisstillinprocessofconnectingatServer.capabilitiesauth_server.js:varexpress=require('express')varbody_pa

c# - 如何使用 MongoDB C# Driver 2.0 创建流畅的聚合

我是MongoDB的新手,我在WebApi中使用它来为移动应用程序提供服务。现在,我需要运行一个聚合,因为我使用的是C#,我想通过使用Aggregate来流畅地完成它集合上的命令返回一个IAggregateFluent.但是,我被卡住了,我在SO上找到的信息对我没有帮助,因此提出了一个新问题。我构建了一个小型集合,其中包含具有一些基本属性的智能手机,智能手机集合中的单个项目看起来像:{"name":"LGNexus5","description":"ANexus5device,createdbyGoogle.","typenr":"LG-NEX-5/WHITE","props":[{"

mongodb - mongo3 升级后获取 DatabaseException 'not authorized for query on db.collection'(代码 = 13)

我使用免费的MongoLab,我的数据库在周末升级到Mongo3,现在我的客户端无法连接。我不断收到“未授权查询db.collection”的消息。错误。Mongolab说我应该使用Mongo3兼容的驱动程序(http://docs.mongodb.org/manual/release-notes/3.0-compatibility/#driver-compatibility-changes)。我正在使用scalaReactiveMongo客户端,版本0.11.7,它应该支持Mongo3。 最佳答案 解决方案是将“?authMode

mongodb - db.getCollectionNames() 等效于 pymongo

mongodbdb.getCollectionNames()命令将为您提供当前数据库中所有集合名称的列表。我想要使用pymongo的相同输出。我用谷歌搜索了一段时间,找不到类似的东西。这样的东西存在吗? 最佳答案 collection_names()将显示当前数据库的集合。来自文档:collection_names()Getalistofallthecollectionnamesinthisdatabase.[readmore] 关于mongodb-db.getCollectionNam

node.js - db.collectionNames 在 Node.js 中不起作用

我想检查Node.js中是否存在一个集合。我使用db.collectionNames获取数据库中的名称列表,但没有任何反应。代码:connectDB(DBURL).then(function(db){console.log('dbconnectok');db.collectionNames('test',function(err,collectionNames){console.log('getcollectionnames');if(err)console.log(err);elseconsole.log(collectionNames);});},function(err){con