bson

How to have a different name for entries of a mongodb document in C#?

て烟熏妆下的殇ゞ 提交于 2019-12-02 11:35:54
问题 I'm trying to do CRUD operations on documents in MongoDB and C# . I would like to have fixed structured domain entities in C# with long meaningful property names but since the name of each property will be saved in MongoDB for each document, that's not a good idea. That's because property names will be redundantly saved in database and affect the total storage and performance. The solution I can think of to overcome this problem, is to use different names for properties in C# than in MongoDB

js-bson error - Mosca (MQTT Broker) on OpenShift

丶灬走出姿态 提交于 2019-12-02 09:27:12
I've been doing some work with NodeJS on OpenShift and am facing a problem when I'm trying to run a Mosca server in a Node instance. The error I'm getting is as follows: [Error: /var/lib/openshift/5547bd284382ec394a000088/app-root/runtime/repo/node_modules/mosca/node_modules/mongodb/node_modules/mongodb-core/node_modules/bson/node_modules/bson-ext/build/Release/bson.node: invalid ELF header] js-bson: Failed to load c++ bson extension, using pure JS version I have recently created a new Application (on OpenShift) from scratch with a NodeJS cartridge and have cloned the sample app git repository

InsertMany Document in a MongoDB Collection using C# BsonArray

我怕爱的太早我们不能终老 提交于 2019-12-02 07:13:36
How to Insert more than one document in a Single statement using InsertMany() MongoDB Method in C# My MongoDB Database and Connections IMongoClient _client; IMongoDatabase _database; _client = new MongoClient(); _database = _client.GetDatabase("test"); var collection = _database.GetCollection<BsonDocument>("EmpInfo"); I'm having a Collection - BsonArray var EmpInfoArray = new BsonArray { new BsonDocument { {"EmpID", "100"}, {"EmpName", "John"}, {"EmpMobile", new BsonArray { new BsonDocument { {"MobNumber", "55566610"}, {"IsPreferred", true}, {"IsLive", false} }, new BsonDocument { {"MobNumber"

How to have a different name for entries of a mongodb document in C#?

筅森魡賤 提交于 2019-12-02 05:48:40
I'm trying to do CRUD operations on documents in MongoDB and C# . I would like to have fixed structured domain entities in C# with long meaningful property names but since the name of each property will be saved in MongoDB for each document, that's not a good idea. That's because property names will be redundantly saved in database and affect the total storage and performance. The solution I can think of to overcome this problem, is to use different names for properties in C# than in MongoDB which means a mapping between them is needed. One elegant way of doing this is to incorporate C#'s

Pymongo BSON Binary save and retrieve?

旧城冷巷雨未停 提交于 2019-12-01 23:13:17
问题 I'm working in Python with MongoDB trying to save an array of floats tightly. I can Create and store correctly * but I CANNOT RETRIEVE THE DATA IN A USABLE FORMAT. >>> import random, array, pymongo >>> from bson.binary import Binary as BsonBinary >>> con = pymongo.Connection('localhost', 27017) >>> mm = con['testDatabase'] >>> vals = [random.random() *100 for x in range(1, 5)] >>> vals [2.9962593, 64.5582810776, 32.3781311717, 82.0606953423] >>> varray = array.array('f', vals) >>> varray

Pymongo BSON Binary save and retrieve?

时光总嘲笑我的痴心妄想 提交于 2019-12-01 22:34:22
I'm working in Python with MongoDB trying to save an array of floats tightly. I can Create and store correctly * but I CANNOT RETRIEVE THE DATA IN A USABLE FORMAT. >>> import random, array, pymongo >>> from bson.binary import Binary as BsonBinary >>> con = pymongo.Connection('localhost', 27017) >>> mm = con['testDatabase'] >>> vals = [random.random() *100 for x in range(1, 5)] >>> vals [2.9962593, 64.5582810776, 32.3781311717, 82.0606953423] >>> varray = array.array('f', vals) >>> varray array('f', [2.9962593, 64.5582810776, 32.3781311717, 82.0606953423]) >>> vstring = varray.tostring() >>>

Has anyone found an efficient way to store BSON ObjectId values in an SQL database?

落爺英雄遲暮 提交于 2019-12-01 21:48:06
We are migrating some data from MySQL to Mongo and have been adding extra fields to some of our DB tables for the ObjectId value of the migrated data objects. At the moment we are storing them as varchar(24) latin1_general_ci which works fine. However, for efficient storage/indexing we probably should convert back to the 12-byte binary value. Unfortunately, MySQL only seems to have native integer support up to 8 bytes . Is there another option - binary perhaps? Update : I am migrating from MySQL but only certain tables at the moment. So I first make duplicates of the objects in Mongo of a

Bson array (de)serialization with Json.NET

ぃ、小莉子 提交于 2019-12-01 16:19:32
I am simply trying to serialize and deserialize a string array in Bson format using Json.NET, but the following code fails: var jsonSerializer = new JsonSerializer(); var array = new string [] { "A", "B" }; // Serialization byte[] bytes; using (var ms = new MemoryStream()) using (var bson = new BsonWriter(ms)) { jsonSerializer.Serialize(bson, array, typeof(string[])); bytes = ms.ToArray(); } // Deserialization using (var ms = new MemoryStream(bytes)) using (var bson = new BsonReader(ms)) { // Exception here array = jsonSerializer.Deserialize<string[]>(bson); } Exception message: Cannot

error in npm install inspite of changing the file Bson

自闭症网瘾萝莉.ら 提交于 2019-12-01 01:00:14
using mongodb3.0, node 0.12.0, npm 2.5.1 on windows 7 integrale, I am trying to read and write data into my database, but i have this error in npm intsall! { [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' } js-bson: Failed to load c++ bson extension, using pure JS version { [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' } js-bson: Failed to load c++ bson extension, using pure JS version i tried to replace bson = require('../build/Release/bson'); into bson = require('../browser_build/bson'); but i had errors like this: exports.BSON

Read BSON (mongoDB) into POJO using GSON and TypeAdapter

耗尽温柔 提交于 2019-11-30 21:13:56
问题 I'm looking for a way to read a MongoDB document into a POJO using GSON. It works just fine until you run into stuff like date's and longs. I would like to write a custom adapter for Gson which will convert any BSON encoded long. Reading this post I have created my own adapter: public class BsonLongTypeAdapter extends TypeAdapter<Long> { @Override public void write(JsonWriter out, Long value) throws IOException { out.beginObject() .name("$numberLong") .value(value.toString()) .endObject(); }