bson

npm install mongoose fails (kerberos and bson errors)

牧云@^-^@ 提交于 2019-12-09 07:46:27
问题 So I'm attempting to launch my node app, but there's a few errors arising from my MongoDB installation. Here are the specs for my dev environment: node => 0.10.33 (installed from nodejs.org) npm => 1.4.28 (installed from nodejs.org) git => 2.1.3 (homebrewed) mongodb => 2.6.5 (homebrewed) If it makes a difference, I am also using the Mean Stack Skeleton as part of a tutorial. In a nutshell, when I try to run my node app using $ node app.js , I get the following feedback: USER$ npm install

Is there a way to store python objects directly in mongoDB without serializing them

丶灬走出姿态 提交于 2019-12-09 04:20:27
问题 I have read somewhere that you can store python objects (more specifically dictionaries) as binaries in MongoDB by using BSON. However right now I cannot find any any documentation related to this. Would anyone know how exactly this can be done? 回答1: There isn't a way to store an object in a file (database) without serializing it. If the data needs to move from one process to another process or to another server, it will need to be serialized in some form to be transmitted. Since you're

mgo - bson.ObjectId vs string id

大憨熊 提交于 2019-12-08 06:56:46
问题 Using mgo , it seems that best practice is to set object ids to be bson.ObjectId . This is not very convenient, as the result is that instead of a plain string id the id is stored as binary in the DB. Googling this seems to yield tons of questions like "how do I get a string out of the bson id?", and indeed in golang there is the Hex() method of the ObjectId to allow you to get the string. The bson becomes even more annoying to work with when exporting data from mongo to another DB platform

Passing Type information to MongoDB so it can deserialize interface types properly?

╄→尐↘猪︶ㄣ 提交于 2019-12-08 06:05:17
问题 I have a class that I serialize into MongoDB as a BsonDocument , this class also happens to have a property of type IMyInterface . public interface IMyInterface { String Name { get; set; } } public class MyClass { public IMyInterface IntRef { get; set; } } During a MyClass object instances lifetime IntRef can reference multiple different classes that implement IMyInterface . Upon serialization I have found that all of the data from the class that IntRef points to is also serialized in the

Mongoose - lean() returning bson data

假装没事ソ 提交于 2019-12-08 05:52:23
问题 This query is not working as expecteed: Model.find().select('_id').lean().exec(function(err, ids) { (...) }) as far as I know lean() method should return the results of the query as js object., not mongodb bson. edit: actual result: forEach(function(item, index, array) { console.log(item); } this: _bsontype=ObjectID, 0=88, 1=198, 2=150, 3=109, 4=7, 5=81, 6=146, 7=44, 8=18, 9=94, 10=112, 11=159 _bsontype=ObjectID, 0=88, 1=198, 2=184, 3=185, 4=19, 5=120, 6=81, 7=12, 8=197, 9=73, 10=143, 11=217

Does order matter in bson_iter_find in mongo c driver

♀尐吖头ヾ 提交于 2019-12-08 02:27:44
问题 I am using mongo c driver 1.1 with mongo version 3.0. Libbson version 1.1. I am using an iterator to look for certain fields in a document. The following code only works when "fieldA" is above "fieldB" in mongodb. If i change the order bson_iter_find returns false. if(bson_iter_find(&iterator,"fieldA")){ pintf("fieldA"); } if(bson_iter_find(&iterator,"fieldB")){ pintf("fieldB"); } In older versions of the libbson(0.4) I was able to use bson_find(), to look for fields in a doc. Is there

mgo - bson.ObjectId vs string id

扶醉桌前 提交于 2019-12-07 06:57:25
Using mgo , it seems that best practice is to set object ids to be bson.ObjectId . This is not very convenient, as the result is that instead of a plain string id the id is stored as binary in the DB. Googling this seems to yield tons of questions like "how do I get a string out of the bson id?", and indeed in golang there is the Hex() method of the ObjectId to allow you to get the string. The bson becomes even more annoying to work with when exporting data from mongo to another DB platform (this is the case when dealing with big data that is collected and you want to merge it with some

Does Key order matter in a MongoDB BSON doc?

元气小坏坏 提交于 2019-12-07 06:22:54
问题 I know certain commends need the hashmap / dictionary to be ordered, but does the actual BSON document in MongoDB matter and would the index still work? E.g. db.people.ensureIndex({LName:1, FName:1}); Would it work on both: {LName:"abc", FName:"def"}, {FName:"ghi", LName:"jkl"} ? Thanks 回答1: The order of a document's properties does not affect indexing. You can see this for yourself by running this query: db.people.find({LName: "abc"}).explain() and then this query: db.people.find({LName:

Encoding custom python objects as BSON with pymongo

旧城冷巷雨未停 提交于 2019-12-07 00:15:05
问题 Is there a way to tell pymongo to use a custom encoder to convert python objects to BSON? Specifically I need to convert numpy arrays into BSON. I know I can manually ensure every numpy array gets converted to a native python array before sending it to pymongo. But this is repetitive and error-prone. I'd much rather have a way to set up my pymongo connection to do this automatically. 回答1: You need to write a SONManipulator . From the docs: SONManipulator instances allow you to specify

How to query date range on the MongoDB collection where the ISO date is stored in string field?

邮差的信 提交于 2019-12-06 19:56:47
问题 Scenario : Consider I am having a collection called MyCollection , with following data: { "_id" : 'MyUniqueID_01' "CreatedTime" : "2013-12-01T14:35:00Z", "LastModifiedTime" : "2013-12-01T13:25:00Z" } Now I want to query the MongoDB database where the above mentioned kind of data is in huge number of documents. And my query is based on date range i.e. using $gt , $gte , $lt & $lte So my query may be something like: db.MyCollection.find({ 'CreatedTime': {$gt: '2013-05-25T09:29:40.572Z'}})