mgo / txn声明集合中的唯一性

I have been trying to insert user info to my mongodb. Since I want both username and email to be unique, I created an email proxy collection for it.

userID := bson.NewObjectId()
emailID := bson.NewObjectId()
tc := mgoSession.DB(DBName).C("transaction")
    runner := txn.NewRunner(tc)
    ops := []txn.Op{{
        C:      "email",
            Id:     emailID,
            Assert: txn.DocMissing,
            Insert: Email{ParentID: userID, Email: email},
        }, {
            C:      "user",
            Id:     userID,
            Assert: txn.DocMissing,
            Insert: User{ID: userID, Username: username, Email: email, RegDate: time.Now(), HashedPw: hashedpw},
        }}
        err = runner.Run(ops, "", nil)
        if err != nil {
            panic(err)
        }

I want to assert uniqueness of email for operation1 and uniqueness of username for operation 2 before insertion. I think I am not using the txn.DocMissing right but I can't find too much information about it on the internet.

From the documentation

// DocExists and DocMissing may be used on an operation's
// Assert value to assert that the document with the given
// Id exists or does not exist, respectively.

...

// Insert holds the document to be inserted at the time the
// transaction is applied. The Id field will be inserted
// into the document automatically as its _id field. The
// transaction will continue even if the document already
// exists. Use Assert with txn.DocMissing if the insertion is
// required.

So what it sounds like to me is if txn.DocMissing is used then the item must be inserted for the transaction to complete. If the insert fails then the transaction will rollback. I don't think it has anything to do with uniqueness. For that you may want to use unique indexes

https://docs.mongodb.com/manual/core/index-unique/

Also more information on how Assert works https://blog.labix.org/2012/08/22/multi-doc-transactions-for-mongodb