考虑这个架构:
let userSchema = new Schema({
email: { type: String, required: true },
password: { type: String, required: true },
books: [{
owner: String,
cover: String,
title: String,
link: String,
requestsReceived: { requestingUser: String, bookOffered: String },
requestsSent: { toUser: String, bookWanted: String },
beingRequested: { type: Boolean, default: false },
beingSent: { type: Boolean, default: false }
}],
ip: String
});
books数组包含包含各种信息的对象。如何从文档1 的数组中获取某个书籍对象,并将其与文档2 的数组交换,最好将最少量的查询交换到数据库。 (即在两个不同的用户文档之间)
我知道这有点困难。非常感谢。