There are several ways:
1- Assuming you are trying to provide a unique identifier for each blog post. Why not rewrite the "_id" field of your documents in your blog collection? Sample document:
{ "_id" : 122 , "content" : { "title: ..... }
You will need to look for a method for generating an auto-increment identifier, although this is quite simple. However, this type of primary key is not recommended. http://www.mongodb.org/display/DOCS/How+to+Make+an+Auto+Incrementing+Field
2- Let the _id field remain as it is, and additionally save the "blogid" key, which is an integer, you will need to run ensureIndex
in the "blogid" field, at least to quickly access Blogid. Storage overhead will be negligible since you will store the key name and integer in the document more.
Document example:
{ "_id" : xxxxxxxxxx ,"blogid" : 122, "content" : { "title: ..... }
source share