I have a table similar to microblog, whose function is to let users see this microblog and stop displaying it.
weibo: {type:String, default:null}
read: {type:objid,default: null}
Do you want to compare them cyclically? I really can’t think of asking for help.
A is the message table, b is read, and c is the user table.
A table is similar to A._id when querying! = (B.read = true and C.uid = 1).readid
Topic table
{ "_id": ObjectId(12345) , "title": "shajiquan.com" }
User table
{ "_id": ObjectId(112233445), "username": "shajiquan.com" }
Read table
{ "user_id": ObjectId(12345), "topic_id": ObjectId(67890) }
# Read by a user has_read = db.read.find({'user_id':USER_ID},{'topic_id':1}) has_read = [i.get('topic_id') for i in list(has_reads)] # Not read by a user topics = db.topics.find({'topic_id':{'$nin':has_read}}) topics = list(topics)