【如何在Spring Data MongoDB中使用低级驱动程序API】教程文章相关的互联网学习教程文章

MongoDB的C#驱动程序教程(译)

草案版本(日期为2010-09-30) 该文件是一个草案版本。虽然我们认为这里提供的信息是非常准确的,它是可能的,它可能会改变未成年人的方式,因为我们吸收用户的反馈意见,并继续执行 C#驱动程序。 1.概述 本教程是10gen支持C#驱动程序MongoDB的介绍。假定草案版本(日期为2010-09-30) 该文件是一个草案版本。虽然我们认为这里提供的信息是非常准确的,香港虚拟主机,它是可能的,它可能会改变未成年人的方式,因为我们吸收用户的...

为什么MongoDB Java驱动程序/ Morphia会在属性之前添加两次?【代码】

这是我的(样本)对象.除了Morphia所需的内容之外,我没有添加任何其他注释:package jungle;@Entity public class Monkey {String name;int bananas;@EmbeddedTreeHouse house; }和TreeHouse对象:@Embedded public class TreeHouse {String type;int distanceFromWater; }我正在尝试使用正则表达式查询类型.这是我正在使用的MongoDB查询(已被证明可通过命令行运行):db.Monkey.find({ "house.type": { "$regex" : ".*coco.*", "$opt...

将查询从MySql查询转换为mongoDB查询并使用php驱动程序【代码】

我必须使用php将此查询从mysql转换为mongoDBSELECT `member_id`, `social_network_id`, `content_type_id` from recent_activity where content_type_id = 10 AND social_network_id = 9 group by member_id order by recent_activity_id desc limit 5我需要这样的结果:array(2) {["content_id"]=>string(6) "122558"["member_id"]=>string(6) "180306",["content_type_id"]=>string(6) "10",["social_network_id"]=>string...

无法使用MongoDB C#2.0驱动程序查询字典项【代码】

我有一个具有字典属性的类.[DataMember][BsonElement("QueriableParameters")]public Dictionary<string, string> QueriableParameters{get;set;}我正在使用新的MongoDB c#2.0驱动程序,但似乎无法做到这一点:var selectQuery1 = await collection.Find(s => s.QueriableParameters["UniqueLoanNumber"] == "3049793b-91eb-49d8-a5b4-7cbfd1a1bb3c").ToListAsync();我收到此错误说明:InnerException: System.InvalidOperationExce...

使用MongoDB C#驱动程序(v2.0)处理收集事件【代码】

使用新的MongoDB驱动程序(v2.0)非常困难.您在网络上找到的大多数示例仍然引用旧版驱动程序.至少可以说,Mongo官方网站上的The reference manual for v2.0是“简洁的”. 我试图做一个简单的事情:检测何时更改了一个集合,以便将C#事件转发到我的服务器应用程序. 为此,我找到了以下C#example(请参见下文),我正在尝试将其转换为新的API.using System; using System.Collections.Generic; using System.Linq; using System.Text; using ...

使用FindOneAndUpdateOptions类C#驱动程序在findAndModify中使用MongoDB映射属性’new’【代码】

我正在尝试为mongoDB实现getNextSequence函数,对此Link进行了解释我正在使用lattes C#驱动程序,但是我不确定如何在FindOneAndUpdateOptions中映射new:true属性 MongoDB代码function getNextSequence(name) {var ret = db.counters.findAndModify({query: { _id: name },update: { $inc: { seq: 1 } },new: true,upsert: true});return ret.seq; }C#代码public async Task<long> GetNextObjectSequenceAsync(string objectName){va...

MongoDB C#驱动程序检查身份验证状态和角色【代码】

这是我使用MongoDB身份验证机制登录MongoDB的代码.try {var credential = MongoCredential.CreateMongoCRCredential("test", "admin", "123456");var settings = new MongoClientSettings{Credentials = new[] { credential }};var mongoClient = new MongoClient(settings);var _database = mongoClient.GetDatabase("test");var collection = _database.GetCollection<Test>("book");var filter = new BsonDocument();var docume...

具有字典的MongoDB C#2.x驱动程序ElemMatch【代码】

我正在尝试使用ElemMatch使用2.2驱动程序在MongoDB中查找文档,但未成功.我收到如下异常:System.InvalidOperationException : The serializer for field‘EnabledForProduct’ must implement IBsonArraySerializer and provideitem serialization info.这是我的班级样子:public class Document {public string Id {get; set;}public Dictionary<Product, bool> EnabledForProduct { get; set; } } public enum Product {Product1...

php-在XAMPP(OS X / El Capitan)上安装MongoDB驱动程序时出错【代码】

我不是XAMPP,PHP或MongoDB的新手,但是我是Mac的新手,因此设置PHP MongoDB driver会给我带来比原来可能更多的麻烦. 当我尝试从/ applications / xampp / xamppfiles / bin运行$sudo pecl install mongodb时,出现此错误:configure: error: Cannot find OpenSSL's <evp.h> ERROR: `/private/tmp/pear/install/mongodb/configure --with-php-config=/usr/bin/php-config' failed因为我是Mac的新手,所以我什至不知道如何解决此错误.我使...

使用MongoDB Java驱动程序备份和还原数据库【代码】

MongoDB Java驱动程序中是否有可能制作备份和还原数据库? 我的解决方案(只需执行命令)现在:public void makeBackUp(String path) {try {Runtime.getRuntime().exec("mongodump --out " + path);} catch (IOException ex) {Logger.getLogger(MongoDB.class.getName()).log(Level.SEVERE, null, ex);}}public void restore(String backUpPath) {try {Runtime.getRuntime().exec("mongorestore " + backUpPath);} catch (IOExceptio...

MongoDB C#驱动程序在take(1)上快速运行,但在take(2)上运行缓慢【代码】

我第一次使用MongoDB C#驱动程序,发现性能出现了一些奇怪的结果.当我查询具有排序和.Take(1)的300万条记录的集合时,响应几乎是瞬时的(3毫秒).但是,当我对同一查询执行(2)时,它最多需要10秒.正确的索引就位,并且它是带有测试数据的非常简单的集合.MongoClient client = new MongoClient(); MongoServer server = client.GetServer();var database = server.GetDatabase("db_name"); var collection = database.GetCollection<MyType...

为什么在MongoDB Java驱动程序中忽略WriteConcern?【代码】

我正在尝试使用MongoDB Java驱动程序执行对db.collection.insert(List< DBObject&gt ;, WriteConcern)方法的阻塞调用.无论我在WriteConcern中使用什么:SAFE,FSYNC_SAFE,FSYNCED,ACKNOWLEDGED,...我都不能授予已执行写入操作……至少不是我现在的操作方式.检查代码: WriteResult result = collection.insert(list, WriteConcern.FSYNC_SAFE); if (result.getN()> 0){ System.out.println("Alleluyah!"); return true; }从我已...

MongoDB C#.Net驱动程序2.0版基于位置的查询【代码】

这适用于1.9database.GetCollection<Places>("Places"); double maxDistanceInRadians = maxDistanceInMiles / 3959.0; var queryplaces = Query.WithinCircle("Loc", lon, lat, maxDistanceInRadians); MongoDB.Driver.MongoCursor cursor = places.Find(queryplaces).SetLimit(limit);如何使用2.0进行位置查询,Query(MongoDb.Drivers.Builder.Query)似乎不是2.0的一部分,这里是doc’s解决方法:检查此页:http://mongodb.github....

在C#中的管道中将$and用于mongodbgregate()函数驱动程序【代码】

我正在尝试使用C#中的mongodb聚合框架. 我希望能够在查询中放入$and.这是我要运行的mongodb查询-db.students.aggregate( {$match:{name:"mira", $and:[{date:{$gte:ISODate("2015-03-01T00:00:00")}}, {date:{$lte:ISODate("2015-04-01T00:00:00")}}]}, {$group:{"_id":"$subject", "$sum":"$marks"}} )我创建了与mongodb查询相对应的匹配项,但此处不正确,因为在括号中出现了编译器错误.我的C#代码如下-var match = new BsonDocume...

如何在OSX上为XAMPP安装PHP MongoDB驱动程序?

我在命令终端上输入了以下命令,以便在Macbook Pro的XAMPP上的PHP中使用“ MongoClient”: >酿造安装wget> brew安装autoconf>须藤/ Applications / XAMPP / xamppfiles / bin / pecl install mongo>在php.ini中添加了extension = mongo.so/ Applications / XAMPP / xamppfiles / etc>重新启动Apache 但是,我没有运气.我不断收到此错误:致命错误:在第5行的/Applications/XAMPP/xamppfiles/htdocs/xampp/index.php中找不到类’Mong...