Q:

How to model a pending trade in MongoDB?

I'm wondering what the "Mongo Way" is for modeling a pending trade of an item between two users.
I have a user collection and I have a book collection.  In my app, the users will be able to propose trades to one another.  Until the trade proposal is accepted, the trade needs to be stored as a pending trade in the database.
It seems to me that the best option is to have a 'trades' property on each book document modeled like this (using Mongoose):
const booksSchema = new Schema({
  title: { type: String, required: true },
  createdAt: { type: Date, 'default': Date.now },
  updatedAt: { type: Date, 'default': Date.now },
  author: { type: String, required: false},
  imageUrl: { type: String, required: false},
  ownerUser: { type: Schema.ObjectId, required: true },
  trades: [{
    fromUser: { type: Schema.ObjectId, required: true },
    bookOffered: { type: Schema.ObjectId, required: true }
  }]
});

The problem I see with this is that it will involve updating two documents when the trade is accepted.  Assuming that the trade is accepted, the ownerUser on each document will need to be changed and the trades array will need to be cleared out.
It seems that to do this you'd want the changes to be in some sort of "Transaction" so that if one didn't update for some reason, then the other wouldn't either.
Is this a typical way to model this type of situation?  What to do about the "Transaction" part of the situation?

A:

There is no way to do a transaction including multiple documents in MongoDB. 
You might consider a separate Trade collection with documents like:
{
   book: ...,
   ownerUser: ...,
   buyerUser: ...,
   status: 'pending' 
   dateSold: null
}

When the trade is approved you can change this document first, then update any related documents next. Should something else fail, this document would decide whether the transaction had actually happened.

