bson

Error thrown when trying to convert from MongoDB BsonArray to IEnumerable<Users> a collection of a POCO instances

ぐ巨炮叔叔 提交于 2019-12-24 11:53:36
问题 All: Here is the information about my development environment: MongoDB 3.0.0 MongoDB C# Driver Version 1.7.0.4714 Microsoft Visual Studio Professional 2013 .NET Framework 4.0 Here is one of the POCO Classes that is used in our project: public class AppUsers { public Object Id { get; set; } public int UserID { get; set; } public int CompanyID { get; set; } public string Username { get; set; } public string Password { get; set; } public int RoleID { get; set; } public DateTime LoginTime { get;

Better explanation of bson spec examples?

☆樱花仙子☆ 提交于 2019-12-24 10:49:37
问题 I'm trying to understand the examples on http://bsonspec.org/#/specification in terms of how the bytes map to the BNF-ish specification, but having a difficult time. Is the text that gets bold when you mouse over either side correctly synchronized with the other side? 回答1: Yes. Here's the Ruby implementation's mapping if you want to verify that the constants are correct. 来源: https://stackoverflow.com/questions/9855681/better-explanation-of-bson-spec-examples

syntax for linking documents in mongodb

[亡魂溺海] 提交于 2019-12-24 06:34:37
问题 If I have two objects in a user collection: {_id: 1, name: 'foo', workItems: []} {_id: 2, name: 'bar', workItems: []} how would I add links to objects in a workItem collection into the workItems array for each user? I understand direct embedding but some workItems will be assigned to multiple users so I don't want to duplicate data. I have looked on mongodb.org but I can't find any examples of linking. 回答1: You can do a DBRef like this: { $ref : <name of collection where reference is>, $id :

Flask app broken after bson update in Heroku

风格不统一 提交于 2019-12-24 04:25:12
问题 I have a Flask app that uses mongoengine and running on Heroku, init I use the bson package and after I updateded it from 0.5.6 to 0.5.7 I started getting the following error message: [2018-11-23 05:56:43 +0000] [39] [INFO] Worker exiting (pid: 39) [2018-11-23 05:56:43 +0000] [40] [ERROR] Exception in worker process Traceback (most recent call last): File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker worker.init_process() File "/app/.heroku

Why does PyMongo encode uuid.uuid1() as a BSON::Binary?

巧了我就是萌 提交于 2019-12-24 04:09:36
问题 I'm adding a 'GUID' key with a value of uuid.uuid1() (from python uuid module) for all my documents in Mongo. I noticed they are being stored not as strings, but as type BSON::Binary . I've done some Googling already, but I still don't understand what the purpose/advantage to this serialization is. Can someone explain? Should I be converting the uuid.uuid1() to strings before storing? How can I use a string to find() by the GUID value like db.myCol.find({ 'GUID' : aString })? 回答1: The default

Can't install js-bson

落爺英雄遲暮 提交于 2019-12-24 02:52:32
问题 I am using Windows 7 64bit, trying to install bson as a dependencie of mongodb. I get this error: npm WARN package.json Wochenplaner@0.0.1 No README.md file found! npm http GET https://registry.npmjs.org/bson npm http 304 https://registry.npmjs.org/bson bson@0.1.5 install C:\Users\Administrator\Dropbox\Projekte\Wochenplaner\node_m odules\bson node install.js || (exit 0) CreateProcessW: Das System kann die angegebene Datei nicht finden. npm ERR! error rolling back Error: ENOTEMPTY, rmdir 'C:

Mongodb import error

放肆的年华 提交于 2019-12-24 01:54:35
问题 I'm ran into a problem using dump/restore to move a MongoDB database from my local machine to the MongoHQ.com. When I restore the dump to MongoHQ it is missing about 10% of the documents with no apparent errors. To troubleshoot I though I would use export/import locally to validate the data and I am getting a error on import, the export did not report any errors. I used json format for the export. Here is one of the import errors; exception:BSON representation of supplied JSON is too large:

Why do I get an error installing bson_ext?

醉酒当歌 提交于 2019-12-24 00:57:05
问题 When I execute the following command in the Rails project folder: gem install bson_ext I get the this error: #result Building native extensions. This could take a while... ERROR: Error installing bson_ext: ERROR: Failed to build gem native extension. /home/absolute/.rvm/rubies/ruby-1.9.3-p0/bin/ruby extconf.rb checking for asprintf()... yes checking for ruby/st.h... yes checking for ruby/regex.h... yes checking for ruby/encoding.h... yes creating Makefile make compiling bson_buffer.c

mongoid scope with referenced object as criteria

柔情痞子 提交于 2019-12-24 00:52:12
问题 I have following scope for Mongoid model in Rails 3: class Expert include Mongoid::Document referenced_in :category scope :currently_available, lambda { |category, limit| limit ||= 5 { :where => {:category => category, :state => 'available'}, :limit => limit } } category here is an instance of referenced model: class Category include Mongoid::Document references_many :experts, :inverse_of => :category When I call the scope as Expert.currently_available(Category.first, 5) , I got a Criteria

How to get size in bytes of bson documents

痴心易碎 提交于 2019-12-23 21:19:48
问题 Is the int value returned by size() function of bson document the number of bytes ? (not able to find the details of this API). How can I get the size of a bson document in bytes? Here is my code. import org.bson.Document; MongoDatabase db...; MongoCollection<Document> mongoCollection = db.getCollection(...); MongoCursor<Document> cursor = mongoCollection.find().iterator(); Document doc = cursor.next(); int size = doc.size(); // does this return number of bytes // how to get size of doc in