Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-2

Remotely shard a collection using the mongodb nodejs driver

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Environment:
      3 servers with 3 shards.

      I'm trying to shard a collection using the mongodb nodejs drive.
      Instead of using the admin ctor, I opened a connection directly to the 'admin' db and issued the following command:
      db.command({shardCollection: 'foo.bar', key: {k:1}})

      I then used the mongo console and issued db.printShardingStatus().
      The result:

      { "_id" : "foo", "partitioned" : true, "primary" : "mongo1" }

      foo.bar chunks:
      mongo1 1
      { "[object Object]" :

      { $minKey : 1 }

      } -->> { "[object Object]" :

      { $maxKey : 1 }

      } on
      : mongo1

      { "t" : 1000, "i" : 0 }

      you can see above that the sharding key object isn't being serialized. and remains [object Object].
      Had I used the mongo console with the same command, the result would have been:
      The result:

      { "_id" : "foo", "partitioned" : true, "primary" : "mongo1" }

      foo.bar chunks:
      mongo1 1
      { "k" :

      { $minKey : 1 }

      } -->> { "k" :

      { $maxKey : 1 }

      } on
      : mongo1

      { "t" : 1000, "i" : 0 }

      where instead of "[object Object]" there was the right "k"

      I digged in the driver and saw that for creating indexes, the driver takes extra effort to serialize them. (db_command.js -> DbCommand.createCreateIndexCommand)
      I guess this is what missing for the shardCollection method for the 'key' property.
      am I doing something wrong? or is this just not supported ?
      If not, does this feature planned to be enabled in the near future?

      Please help

      Thanks you,

      Uri

            Assignee:
            christkv Christian Amor Kvalheim
            Reporter:
            urigolani uri golani
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: