_id has to be unique within one collection or in all collection put together in db

Hello,
_id of documents has to be unique within one collection or in all collections put together in db?

Unique within one collection. Try the following:

> use test
> db.a.insertOne( { _id : 1 } )
> db.a.insertOne( { _id : 1 } )
> db.b.insertOne( { _id : 1 } )
> db.a.find()
> db.b.find()