我使用 mongo 2.6.4/Windows Server 2012 R2。
Mongodump 生成了两个转储文件:mongodump -d mydb
mongorestore --host 127.0.0.1 --port 27018 --collection transaction --db mydb2015-08-17T19:45:51.844+0400 Failed: restore error: mydb.transaction: error restoring from F:\restore\transaction.bson: insertion error: Client Error: bad object in message: invalid bson type in object with _id: ObjectId('528dc7c03599b01214d17469')mongorestore --host 127.0.0.1 --port 27018 --collection transaction --db mydb --drop --noIndexRestore --noOptionsRestore --noobjcheck --filter "{'_id' : { $ne: '528dc7c03599b01214d17469' }}" F:/restore/transaction.bsonmongorestore /host 127.0.0.1 /port 27018 /collection transaction /db mydb /drop /noIndexRestore /noOptionsRestore /keepIndexVersion F:/restore/transaction.bson2015-08-17T19:14:32.447+0400 [conn8] Assertion: 10307:Client Error: bad object in message: invalid bson type in object with _id: ObjectId('528dc7c03599b01214d17469')
2015-08-17T19:14:32.532+0400 [conn6] insert mydb.transaction ninserted:10000 keyUpdates:0 numYields:0 locks(micros) w:181893 181ms
2015-08-17T19:14:32.743+0400 [conn9] insert mydb.transaction ninserted:10000 keyUpdates:0 numYields:0 locks(micros) w:211264 211ms
2015-08-17T19:14:32.921+0400 [conn7] insert mydb.transaction ninserted:10000 keyUpdates:0 numYields:0 locks(micros) w:176525 177ms
2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\mongo\util\stacktrace.cpp(169) mongo::printStackTrace+0x43
2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\mongo\util\log.cpp(127) mongo::logContext+0x9c
2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\mongo\util\assert_util.cpp(183) mongo::msgasserted+0xfb
2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\mongo\util\assert_util.cpp(174) mongo::msgasserted+0x13
2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\mongo\db\dbmessage.cpp(116) mongo::DbMessage::nextJsObj+0x11f
2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\mongo\db\instance.cpp(898) mongo::receivedInsert+0x18f
2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\mongo\db\instance.cpp(484) mongo::assembleResponse+0x7c9
2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\mongo\db\db.cpp(202) mongo::MyMessageHandler::process+0x111
2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\mongo\util\net\message_server_port.cpp(210) mongo::PortMessageServer::handleIncomingMsg+0x671
2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\third_party\boost\libs\thread\src\win32\thread.cpp(185) boost::'anonymous namespace'::thread_start_function+0x21
2015-08-17T19:14:36.250+0400 [conn8] mongod.exe f:\dd\vctools\crt_bld\self_64_amd64\crt\src\threadex.c(314) _callthreadstartex+0x17
2015-08-17T19:14:36.250+0400 [conn8] mongod.exe f:\dd\vctools\crt_bld\self_64_amd64\crt\src\threadex.c(292) _threadstartex+0x7f
2015-08-17T19:14:36.250+0400 [conn8] KERNEL32.DLL BaseThreadInitThunk+0xd
2015-08-17T19:14:36.250+0400 [conn8]
2015-08-17T19:14:36.255+0400 [conn8] insert mydb.transaction keyUpdates:0 exception: Client Error: bad object in message: invalid bson type in object with _id: ObjectId('528dc7c03599b01214d17469') code:10307 numYields:0 0ms最佳答案
mongodump最好转储整个数据库。如果您只想处理一个集合,请尝试导出 transaction收藏与 mongoexport喜欢 mongoexport --collection transaction --db mydb --out transaction.json并使用 mongoimport --collection transaction --db mydb --file transaction.json 导入它.
如果您正在恢复一个完整的转储并且它因某个集合而失败,那么您可以使用以下标志 --excludeCollection transaction 在没有违规集合的情况下进行恢复。
关于mongodb - mongorestore 不会跳过没有/stopOnError 标志的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32055177/
大约一年前,我决定确保每个包含非唯一文本的Flash通知都将从模块中的方法中获取文本。我这样做的最初原因是为了避免一遍又一遍地输入相同的字符串。如果我想更改措辞,我可以在一个地方轻松完成,而且一遍又一遍地重复同一件事而出现拼写错误的可能性也会降低。我最终得到的是这样的:moduleMessagesdefformat_error_messages(errors)errors.map{|attribute,message|"Error:#{attribute.to_s.titleize}#{message}."}enddeferror_message_could_not_find(obje
我好像记得Lua有类似Ruby的method_missing的东西。还是我记错了? 最佳答案 表的metatable的__index和__newindex可以用于与Ruby的method_missing相同的效果。 关于ruby-难道Lua没有和Ruby的method_missing相媲美的东西吗?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/7732154/
我有一个奇怪的问题:我在rvm上安装了rubyonrails。一切正常,我可以创建项目。但是在我输入“railsnew”时重新启动后,我有“程序'rails'当前未安装。”。SystemUbuntu12.04ruby-v"1.9.3p194"gemlistactionmailer(3.2.5)actionpack(3.2.5)activemodel(3.2.5)activerecord(3.2.5)activeresource(3.2.5)activesupport(3.2.5)arel(3.0.2)builder(3.0.0)bundler(1.1.4)coffee-rails(
设置:狂欢ruby1.9.2高线(1.6.13)描述:我已经相当习惯在其他一些项目中使用highline,但已经有几个月没有使用它了。现在,在Ruby1.9.2上全新安装时,它似乎不允许在同一行回答提示。所以以前我会看到类似的东西:require"highline/import"ask"Whatisyourfavoritecolor?"并得到:Whatisyourfavoritecolor?|现在我看到类似的东西:Whatisyourfavoritecolor?|竖线(|)符号是我的终端光标。知道为什么会发生这种变化吗? 最佳答案
我想在一个没有Sass引擎的类中使用Sass颜色函数。我已经在项目中使用了sassgem,所以我认为搭载会像以下一样简单:classRectangleincludeSass::Script::FunctionsdefcolorSass::Script::Color.new([0x82,0x39,0x06])enddefrender#hamlengineexecutedwithcontextofself#sothatwithintemlateicouldcall#%stop{offset:'0%',stop:{color:lighten(color)}}endend更新:参见上面的#re
我在我的Rails项目中使用Pow和powifygem。现在我尝试升级我的ruby版本(从1.9.3到2.0.0,我使用RVM)当我切换ruby版本、安装所有gem依赖项时,我通过运行railss并访问localhost:3000确保该应用程序正常运行以前,我通过使用pow访问http://my_app.dev来浏览我的应用程序。升级后,由于错误Bundler::RubyVersionMismatch:YourRubyversionis1.9.3,butyourGemfilespecified2.0.0,此url不起作用我尝试过的:重新创建pow应用程序重启pow服务器更新战俘
当我的预订模型通过rake任务在状态机上转换时,我试图找出如何跳过对ActiveRecord对象的特定实例的验证。我想在reservation.close时跳过所有验证!叫做。希望调用reservation.close!(:validate=>false)之类的东西。仅供引用,我们正在使用https://github.com/pluginaweek/state_machine用于状态机。这是我的预订模型的示例。classReservation["requested","negotiating","approved"])}state_machine:initial=>'requested
我遵循MichaelHartl的“RubyonRails教程:学习Web开发”,并创建了检查用户名和电子邮件长度有效性的测试(名称最多50个字符,电子邮件最多255个字符)。test/helpers/application_helper_test.rb的内容是:require'test_helper'classApplicationHelperTest在运行bundleexecraketest时,所有测试都通过了,但我看到以下消息在最后被标记为错误:ERROR["test_full_title_helper",ApplicationHelperTest,1.820016791]test
我是rails的新手,想在form字段上应用验证。myviewsnew.html.erb.....模拟.rbclassSimulation{:in=>1..25,:message=>'Therowmustbebetween1and25'}end模拟Controller.rbclassSimulationsController我想检查模型类中row字段的整数范围,如果不在范围内则返回错误信息。我可以检查上面代码的范围,但无法返回错误消息提前致谢 最佳答案 关键是您使用的是模型表单,一种显示ActiveRecord模型实例属性的表单。c
我正在尝试编写一个将文件上传到AWS并公开该文件的Ruby脚本。我做了以下事情:s3=Aws::S3::Resource.new(credentials:Aws::Credentials.new(KEY,SECRET),region:'us-west-2')obj=s3.bucket('stg-db').object('key')obj.upload_file(filename)这似乎工作正常,除了该文件不是公开可用的,而且我无法获得它的公共(public)URL。但是当我登录到S3时,我可以正常查看我的文件。为了使其公开可用,我将最后一行更改为obj.upload_file(file