开发者

NodeJS and Mongoose with Mongodb sharding issue

I have been using NodeJS, MongooseJS with Mongodb. It is throwing the following error when i try to insert an record in mongodb using mongooseJS

"MongoError: right object doesn't have full shard key"

FYI: MongoDB Table having shard key

Plea开发者_开发问答se tell me how to resolve this issue! and what is that error mean?


When you are inserting any object into Mongo collection which has shard key, object should have all shard keys (i.e. full shard key).

As mongodb's doc says:

All (non-multi)updates, upserts, and inserts must include the current shard key."

current shard key in the sense all the shard key which are currently applicable.


Mongoose 2.5.3 has support for sharding, just include the shardkey in the schema options and Mongoose does the rest.

var LoginSchema = new Schema({attribut: String}, 
                             { shardkey: { at: 1, _user: 1 }}
                            )
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜