lanwin edited this page Sep 13, 2010 · 11 revisions
Clone this wiki locally

Secure communication/connection

MongoDB currently does not provide any way of dong this, so our driver also can not provide this feature.

An way to solve that could be to tunnel you connections via SSH or VPN

Why System.Decimal is not supported

MongoDB uses BSON to store its data. BSON currently does not support Decimal values because there are a lot of languages that do not support Decimal to (like Javascript which MongoDB uses internally).

You can solve that by:

  • Converting it to double
    • Pro: All database operators like $inc are working
    • Con: You lost precision
  • Converting it to MongoDB.Binary
    • Pro: You keep precision
    • Con: Database operators like $inc does not work
  • Create a wrapper class which holds the spitted value
    • Pro: You keep precision
    • Pro: Other drivers can simply read the simple values
    • Con: Database operators like $inc does not work
  • Use Integers and support the precision you want
    • Pro: You keep precision
    • Pro: It’s still queryable
    • Con: It’s a manual fix on a per app basis

Can i run Mongo client command x?

Yes, but you have to be aware that some client commands dose not directly map to database commands. Instead they are a batch of javascript which sends real database commands. You can check that if you execute the client function without colons.

To execute a database command which is not directly mapped to a function in MongoDB-CSharp, review the list of available commands here http://www.mongodb.org/display/DOCS/List+of+Database+Commands. From there you can get the document which you need to send to the database to execute that command. In my example i choose serverStatus. So my document looks like {serverStatus:1}.

To send that command to database, you simply need to run the MongoDatabase.RunCommand function.

Full example:

var request = new Document(“serverStatus”,1);
var status = myDatabase.RunCommand(request);