草庐IT

datetime_index_test

全部标签

mongodb - 如何将一个class item装饰成一个index,得到和ensureIndex一样的效果?

我想在类声明中定义哪些项目是索引,比如:publicclassMyClass{publicintSomeNum{get;set;}[THISISANINDEX]publicstringSomeProperty{get;set;}}因此与ensureIndex("SomeProperty")具有相同的效果这可能吗? 最佳答案 我认为这是个好主意,但你必须自己做,没有内置支持。如果你有一个访问层,你可以在那里做。你需要一个属性类,像这样;publicenumIndexConstraints{Normal=0x00000001,//Asc

java - Spring 数据蒙戈 |无法授权在没有字符串类型的情况下插入 system.indexes 文档

我在尝试创建SpringDataMongoRepository时遇到问题。相关代码&配置:-模型类:-@Document(collection="USER_DETAIL")publicclassUserDetailimplementsorg.springframework.security.core.userdetails.UserDetails,Serializable{privatestaticfinallongserialVersionUID=-2637223077307659181L;@IdprivateStringid;@Indexed(dropDups=true,name=

c# - MongoDB C# 驱动程序和 DateTime 字段

我正在使用C#驱动程序将文档插入MongoDB集合,当我调试应用程序时,其中一种字段类型与DateTime相比,我在传递给Mongo的“FrameTimeStamp”字段中看到服务器时间,这是我的代码:FrameDocumentframeDoc=newFrameDocument();frameDoc.Frame=imageBA;frameDoc.EventCodeId=1;frameDoc.SesionId=1;frameDoc.FrameTimeStamp=DateTime.Now;frameDoc.ServerUserId=(int)toMongoDt.Rows[0]["Serve

python - 为什么 DuplicateKeyError : E11000 duplicate key error index: test. test.$notification_1 dup key: { : null }

我像这样创建唯一索引:self.db_database[co_name].ensure_index([('src_md5',-1),('src_time',-1),('src_size',-1)],unique=True)self.db_database[co_name].ensure_index(('notification'),unique=True)self.db_database[co_name].ensure_index(('version'),unique=True)`在插入之前我创建一条记录如下:self.db_database[co_name].insert({"not

spring - 当事件配置文件为 "test"时使用嵌入式 MongoDB

我有org.springframework.bootspring-boot-starter-data-mongodb在我的pom.xml中,因此我的SpringBoot应用程序会在应用程序启动时尝试连接到本地主机上的MongoDB。我也有de.flapdoodle.embedde.flapdoodle.embed.mongotest因此,当我运行单元测试时,会使用嵌入式MongoDb。出于集成测试的目的,如果应用程序以“测试”事件配置文件启动,我还想使用嵌入式MongoDB。如此有效,我想删除test来自嵌入依赖项,并在事件配置文件为“测试”时使用嵌入版本。我怎样才能做到这一点?

indexing - 如何在生产中有效地建立 "defragment"MongoDB 索引?

我一直在研究MongoDB。感觉不错。我在集合中添加了一些索引,上传了一堆数据,然后删除了所有数据,我注意到索引没有改变大小,类似于报告的行为here.如果我打电话db.repairDatabase()然后索引被压缩到接近于零。同样,如果我不删除所有数据,而是调用repairDatabase(),索引会稍微压缩(可能是因为未使用的扩展被截断了?)。我从db.collection.stats()的“totalIndexSize”获取索引大小。但是,这需要很长时间(我读到在大型数据库上可能需要数小时)。我不清楚数据库在运行时读取或写入的可用性如何。我猜不太可用。由于我想运行尽可能少的mon

javascript - meteor js : Create text index in collection

我创建了一个带有名称和描述字段的类别集合。即Categories=newMeteor.Collection('categories');CategoriesSchema=newSimpleSchema({translation:{type:[Object]},"translation.$":{type:Object},"translation.$.name":{type:String},"translation.$.description":{type:String}});Categories.attachSchema(CategoriesSchema);我需要创建一个文本索引来按名称

datetime - 在 mongoDB 中使用日期时间的最佳方式是什么

我正在解析nginx日志,我想将日志中的日期和时间存储到mongodb..我将日期作为字符串(格式为yyyy-mm-dd)存储在我的数据库中,我的编程语言是perl。什么是存储日期的最有效方法。我应该使用perl日期时间模块来格式化日期吗?“日期”:“SunFeb13201105:30:00GMT+0530(IST)”我真的很想了解在mongodb中存储日期的最佳方式是什么。请指导我 最佳答案 我想对于故事日期的日志最好是日期而不是字符串,因为使用字符串您将无法查询从一个日期到另一个日期(范围)的日志。我想您会比其他人更多地使用范围

MongoDB ODM 索引 : How to Index multiple Compound index on a documnt that have EmbeddedDocument in itself?

我有这个类(class):/***@ODM\Document*@Indexes({*@Index(keys={"status"="asc","regDate"="desc","expDate"="asc","isFeatured"="asc"}),*@Index(keys={"status"="asc","visits.total"="asc","visists.today"="asc"}),*@Index(keys={"status"="asc","price.value"="asc","regDate"="asc"})*})*/classProduct{/***@ODM\Date*

mongodb - MongoError : can't find any special indices: 2d (needs index), 2dsphere(需要索引)

我正在尝试通过使用MongoDB的查找方法查询特定点周围的纬度和经度点来使用MongoDB的地理空间索引。我不断收到错误消息:MongoError:can'tfindanyspecialindices:2d(needsindex),2dsphere(needsindex)在谷歌搜索了大约一个小时后,我不确定文档在哪里。我也找不到任何好的解释。这是我使用Mongoose创建的架构:varmongoose=require('mongoose');varSchema=mongoose.Schema;varEventSchema=newSchema({name:String,descripti