Skip to content

scott4dev/ObjectId

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Mongo data center aware ObjectId

This is just an idea on MongoDB ObjectId

If you want to split data on multiple shards using only the _id field

sh.enableSharding("demo");
sh.shardCollection("demo.foo", { _id : 1 } );
sh.addTagRange("demo.foo", { _id: MinKey }, { _id: ObjectId("640000000000000000000000") }, "DC1");
sh.addTagRange("demo.foo", { _id: ObjectId("640000000000000000000000") }, { _id: MaxKey }, "DC2");

When the app starts you have to set the right value for the data-center identifier to target data to desired data-center using only the _id field

DataCenterAwareIdGenerator.DataCenter = 200;

About

Mongo data center aware ObjectId

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages