Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用:nodejs、express、socket.io、redis、mongodb 进行实时聊天项目。我想问人们如何在 mongodb 上保存消息。我尝试将每条聊天线保存到mongodb中,但是聊天太多保存了很多,当我想访问它时,我必须访问太多。是否有最佳方法来保存这种情况。感谢大家 !
也许您应该尝试限制消息。例如获取最后 10 个条目
db.getLastInsertedDocument.find({}).sort({_id:-1}).limit(10);